0
在我的應用程序要求是從圖庫中選擇圖像,然後裁剪所選圖像並設置爲圖像視圖。以下是我裁剪圖像的示例代碼。如何使用默認裁剪意圖裁剪android棉花糖中的圖像?
//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棉花糖圖謀但是Android蜀葵,它是crashing.How解決這個問題?
[Android沒有'CROP'' Intent'](https://commonsware.com/blog/2013/01/23/no-android-does-not-have-crop-intent.html)。有很多[可用於Android的圖像裁剪庫](https://android-arsenal.com/tag/45)。請使用一個。 – CommonsWare
@CommonsWare感謝您的回覆,是android棉花糖沒有作物意圖? – Rajesh
@CommonsWare我試圖添加裁剪庫,但應用程序大小增加。這就是我尋找默認裁剪的原因 – Rajesh