Android:相机应用在某些手机上因裁剪而导致 ACTION_IMAGE_CAPTURE 中断
下面的代码请求一张新图片,裁剪它并将数据写入临时文件中。它在运行 Android 2.2.1 的 HTC Desire HD 上运行良好。
但在 Android 2.2 的华为 Ideos 上,相机应用程序停止(应用程序相机意外停止),而我的应用程序继续运行,但没有拍摄任何照片。一位使用 EVO 4G、Android 2.3.3 的用户报告了类似的问题(可能相同)。
在 Ideos 手机上,我在拍照后看不到裁剪框,所以我猜这就是相机应用程序崩溃的地方,我猜这可能取决于相机应用程序的设备特定实现。有人有解决办法吗?
case 1:
Uri mSavedUri = Uri.fromFile(new File(basepath + "/temp" + imgExtension));
Intent newphoto = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
newphoto.putExtra("crop", "true");
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;
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", "true");
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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Android 相机实现有很大不同,并且不支持所有
选项相同。尝试从意图中删除所有不相关的设置 - 它们
可能会混淆一些相机应用程序
我的第一个候选者是:noFaceDetection & noFaceDetection设置壁纸
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