I've implemented taking picture and cropping it in my app. Usually it works perfectly. But the problem appears on devices with Cooliris gallery. The message "Gallery(process com.cooliris.media) has stopped unexpectedly" appears after the image is taken. Unfortunately, I don't have such device, and can't test it. But I have a stacktrace from a crash log.
E/AndroidRuntime(20624): Caused by: java.lang.NullPointerException
E/AndroidRuntime(20624): at com.cooliris.media.CropImage.loadBitmap(CropImage.java:460)
E/AndroidRuntime(20624): at com.cooliris.media.CropImage.onCreate(CropImage.java:443)
E/AndroidRuntime(20624): at android.app.Activity.performCreate(Activity.java:4465)
E/AndroidRuntime(20624): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1052)
E/AndroidRuntime(20624): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1932)
E/AndroidRuntime(20624): ... 11 more
The code I use to take a photo:
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
imageCaptureUri = Uri.fromFile(getTempImageFile());
intent.putExtra("return-data", true);
startActivityForResult(intent, INTENT_PICK_FROM_CAMERA);
The code to crop the image (in onActivityResult for this intent):
Intent intent = new Intent("com.android.camera.action.CROP");
intent.addCategory("android.intent.category.DEFAULT");
intent.addCategory("android.intent.category.ALTERNATIVE");
intent.addCategory("android.intent.category.SELECTED_ALTERNATIVE");
intent.setDataAndType(data.getData(), "image/jpeg");
intent.putExtra("outputX", CROPPED_IMAGE_X);
intent.putExtra("outputY", CROPPED_IMAGE_Y);
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("scale", true);
intent.putExtra("return-data", true);
startActivityForResult(intent, INTENT_CROP_FROM_CAMERA);
Seems like data.getData() is null, but I'm not sure. Does anybody know what can be the issue and how to fix it?