【发布时间】:2015-06-18 13:57:13
【问题描述】:
我有一个关于 onActivityResult 在从意图打开相机后没有被调用的问题:
Intent takeIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
有额外的:
takeIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
在 ZTE Blade III 上,我可以打开相机,但是当我按下“勾号”时,没有任何反应,好像相机本身有一些异常,并且控件不会返回调用活动 - onActivityResult 不会被调用。
在其他没有系统的手机(中兴通讯是 4.0.4)上一切正常。我还可以向 Intent 添加额外的“返回数据”,但结果是我不想要的缩略图。
PS。 photoFile 的创建方式如下:
private File createImageFile() throws IOException {
// Create an image file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "JPEG_" + timeStamp + "_";
File storageDir = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);
File image = File.createTempFile(
imageFileName, /* prefix */
".jpg", /* suffix */
storageDir /* directory */
);
photoPath = image.getAbsolutePath();
return image;
}
【问题讨论】:
标签: android android-intent camera storage