I'm developing an app using a camera intent to take a photo and an image view to show it. I've two problems, first is with the camera.
I have an activity only to manage the camera behaviour, the code of this manager is based on the sample of developer.google.com. The issue is on the camera interface. When I open the camera on vertical position, take a photo and accept de preview, all the process on vertical position, all works fine. The same behaviour with horizontal position.
But If accepts the photo preview in a different position how was started the camera interface, don't ends. It seems like the camera were restarted and I can take another photo. In addition, when this occurs the photo is not saved correctly, on gallery I don't see the picture, has a message 'Couldn't load photo'.
My other problem it's similar, but this time occurs on an ImageView. When I have the ImageView setted with an image, after rotate my device the image disappears. This issue only occurs when I've taken a new photo, if the image is already in system all works fine.
EDIT:
static final int REQUEST_IMAGE_CAPTURE = 1;
OnClick {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File f = null;
try {
f = createImageFile();
mCurrentPhotoPath = f.getAbsolutePath();
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
} catch (IOException ex) {
ex.printStackTrace();
mCurrentPhotoPath = null;
}
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
}
OnActivityResult {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
if (mCurrentPhotoPath != null) {
galleryAddPic(); //Method to save the pic in the gallery
finishActivity();
} else {
Log.e("ActivityResult", "Photo path is null");
}
} else if (resultCode == RESULT_CANCELED) {
finishActivity();
}
}
EDIT 2: I just resolve the second issue, I'm beginner on developing apps and I don't knew that rotate the device restarts the interface and all modifications on the data after OnCreate should be saved on OnSaveInstanceState.
Now I only have one problem. I try it the strange behaviour in other device and it's the same.