At my software developing company, we are developing multiples Android apps that use the camera to take pictures. We found an unsolvable problem in two Sony devices: The onActivityResult
method is not called by the Camera Intent, so there is no event triggered on the app to handle the image file and continue the app process. We don't know why and neither how to handle the problem.
This is the way we use to call the camera, from a Fragment:
public void takePicture() {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) {
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "JPEG_" + timeStamp + ".jpg";
File storageDir = new File(PATH_TO_IMAGES);
File imageFile = new File(storageDir.getAbsolutePath(), imageFileName);
mImagePath = imageFile.getAbsolutePath();
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile));
mIsTakingPicture = true;
startActivityForResult(takePictureIntent, TAKE_PICTURE);
}
}
The questions are:
Have you experienced this problem with some devices? Specifically, the Sony Xperia Devices? The Sony devices that present this problem were Sony Xperia E4 and Sony C2104.
How do we handle the problem before launching the camera? How can we tell the
onActivityResult
method was not called back?