对于从 Lollipop 及以上版本的 android 手机拍摄的裁剪图像一个应该使用文件提供程序这里是我的代码。
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.example.test.fileprovider"
android:grantUriPermissions="true"
android:exported="false"
>
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths"
/>
</provider>
<paths>
<external-path name="myexternalimages" path="dcim/ProfileImage/"/>
</paths>
final Uri providedUri = FileProvider.getUriForFile(ProfileUpdateActivity.this,
"com.example.test.fileprovider", imageUpLoadFile);
Intent cropIntent = new Intent("com.android.camera.action.CROP");
//indicate image type and Uri
cropIntent.setDataAndType(providedUri, "image/*");
//set crop properties
cropIntent.putExtra("crop", "true");
//indicate aspect of desired crop
cropIntent.putExtra("aspectX", 1);
cropIntent.putExtra("aspectY", 1);
//indicate output X and Y
cropIntent.putExtra("outputX", 256);
cropIntent.putExtra("outputY", 256);
//retrieve data on return
cropIntent.putExtra("return-data", true);
// Exception will be thrown if read permission isn't granted
cropIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivityForResult(cropIntent, PIC_CROP);
where imageUploadFile =/storage/emulated/0/dcim/ProfileImage/IMG_20160330_134823_1697877403.png (Example)
现在,当它成功返回 onActivityResult 时,我收到一条错误消息,因为无法编辑此图像