0
我與Android裁剪圖像的工作,這是我裁剪圖像代碼:android-進行裁剪圖像不正常
private void performCrop() {
try {
Intent cropIntent = new Intent("com.android.camera.action.CROP");
//indicate image type and Uri
cropIntent.setDataAndType(picUri, "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", 500);
cropIntent.putExtra("outputY", 500);
//retrieve data on return
cropIntent.putExtra("return-data", true);
//start the activity - we handle returning in onActivityResult
startActivityForResult(cropIntent, PIC_CROP);
} catch (ActivityNotFoundException anfe) {
//display an error message
String errorMessage = "err";
Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
toast.show();
}
}
我已經測試此代碼在Android 4.2,4.3和無問題,但在android 5,6上,它返回空指針異常,我不知道爲什麼。
這段代碼有什麼問題?我怎樣才能使它與Android的所有版本兼容?
確保您爲Android 6應用了權限模型 – Jai
將您的logcat –