In my application requirement is select the image from gallery and then crop the selected image and set to the imageview. Below is my sample code for cropping the image.
//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);
Above code is works fine in below android marshmallow devises but android marsh mallow it is crashing.How to solve the issue?