在我的应用程序要求中,从图库中选择图像,然后裁剪所选图像并设置为图像视图。下面是我裁剪图像的示例代码。
//call the standard crop action intent (the user device may not support it)
Intent cropIntent = new Intent("com.android.camera.action.CROP");
cropIntent.setClassName("com.android.camera", "com.android.camera.CropImage");
//indicate image type and Uri
cropIntent.setDataAndType(mImageCaptureUri, "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);
cropIntent.putExtra(MediaStore.EXTRA_OUTPUT, mImageCaptureUri);
cropIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
//start the activity - we handle returning in onActivityResult
startActivityForResult(cropIntent, PIC_CROP);
上面的代码在下面的 android marshmallow 设计中运行良好,但是 android marsh mallow 它崩溃了。如何解决这个问题?