Issue
I'm trying to take a picture from the Camera using intent with onActivityResult
but every time I take a picture the camera locks up and never returns. Any reason why this might happen? This is the code I'm using:
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.v(TAG,"Camera callback: "+Integer.toString(resultCode));
if (requestCode == CAMERA_PIC_REQUEST) {
try{
Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
Log.v("Picture view",data.getData().toString());
ImageView image = new ImageView(this);
image.setImageBitmap(thumbnail);
setContentView(image);
}
catch(Exception e){
Log.e(TAG, "something happened");
e.printStackTrace();
}
}
}
This is the LogCat output after taking a picture:
06-12 19:46:03.881: VERBOSE/camera(443): Start autofocus.
06-12 19:46:04.521: VERBOSE/camera(443): doSnap: mFocusState=1
06-12 19:46:04.721: VERBOSE/camera(443): mAutoFocusTime = 790ms
Then it just locks up and onActivityResult
never fires.
Thanks for your inputs.
Solution
I read a bunch of tutorials and everyone does it different. The official Android Docs use the Camera-class (step by step tutorial on the linked page).
I found this other tutorial (which uses the MediaStore
-class, like you), but put an extra for the Output-File on the Intent.
You might want to check both of this tutorials and see if one works for you.
Answered By - Lukas Knuth
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.