Android: camera app breaks on ACTION_IMAGE_CAPTURE with crop on some phones
The code below below requests a new picture, crops it and writes the data in a temp file. It works very well on an HTC Desire HD with Android 2.2.1.
But on a Huawei Ideos with Android 2.2 the camera application stops (the Application Camera has stopped unexpectedly) and my app continues without any picture taken. A similar problem (probably the same) has been reported by a user with EVO 4G, Android 2.3.3.
On the Ideos phone I don't see the crop box after taking the picture, so I guess that is where the camera application breaks, and I guess this may depend on device specific implementations of the camera app. Anyone has a solution?
case 1:
Uri mSavedUri = Uri.fromFile(new File(basepath + "/temp" + imgExtension));
Intent newphoto = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
newphoto.putExtra("crop", "tru开发者_如何学Goe");
newphoto.putExtra("outputX", imageSizeX);
newphoto.putExtra("outputY", imageSizeY);
if (imageAspect == 0) {
newphoto.putExtra("aspectX", 1);
newphoto.putExtra("aspectY", 1);
}
if (imageAspect == 1) {
newphoto.putExtra("aspectX", 4);
newphoto.putExtra("aspectY", 3);
}
if (imageAspect == 2) {
newphoto.putExtra("aspectX", 3);
newphoto.putExtra("aspectY", 4);
}
newphoto.putExtra("scale", true);
newphoto.putExtra("noFaceDetection", true);
newphoto.putExtra("setWallpaper", false);
newphoto.putExtra("output",mSavedUri);
startActivityForResult(newphoto, NEW_PHOTO);
break;
Android camera implementations are pretty different, and do not support all the options equally. Try to remove all the irrelevant settings from intent - they may confuse some camera apps
My first candidates would be: noFaceDetection & setWallpaper
精彩评论