【发布时间】:2016-02-12 07:57:18
【问题描述】:
我正在尝试使用MediaStore.ACTION_IMAGE_CAPTURE Intent 拍摄个人资料照片。
启动意图的代码:
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File myPicture = new File(OfflineApp.getAppContext().getFilesDir() + "/" + getResources().getString(R.string.contact_photos_dir), getResources().getString(R.string.my_photo_file_name));
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(myPicture));
startActivityForResult(cameraIntent, REQUEST_CODE_TAKE_PHOTO);
还有 onActivityResult 部分:
case REQUEST_CODE_TAKE_PHOTO:
if (resultCode == RESULT_OK) {
String path = new File(OfflineApp.getAppContext().getFilesDir() + "/" + getResources().getString(R.string.contact_photos_dir), getResources().getString(R.string.my_photo_file_name)).getAbsolutePath();
ContactManager.getInstance().updateMyImage(path);
}
break;
但是,结果代码总是RESULT_CANCELED,只有我提供MediaStore.EXTRA_OUTPUT,即使文件不存在。
【问题讨论】:
标签: android android-intent android-camera mediastore