You do not have
setContentView(R.layout.mylayout);
So
ImageView iv = (ImageView) findViewById(R.id.image_frame);// fails
findViewById
looks for a view with the id mentioned in the current inflateed layout. So you need to set the content of the layout to the activity first and then initialize views.
ImageView iv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mylayout);
iv = (ImageView) findViewById(R.id.image_frame);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, CAMERA_REQUEST_KEY);
}
Make sure you have the required permission in manifest file
http://developer.android.com/reference/android/hardware/Camera.html