我的Galaxy Nexus現在在Android 4.3上運行,允許我使用此新版本測試我的應用程序。一切似乎都很好,除了裁剪。Android 4.3 crop gallery resultCode取消
我有一個應用程序,使用相機拍照,然後通過畫廊應用程序裁剪圖像。
我也可以從畫廊中選擇一張圖片並剪下。 自Android 4.3以來,圖庫應用程序發生了變化。
如果我採取與照相機API圖片,然後問畫廊裁剪它在我onActivityResult方法發送resultCode設置爲0(意思是取消),而我從作物意見「保存」點擊。
但是,如果我從圖庫中選擇一張圖片並裁切一切正常,則resultCode參數設置爲-1。 我在這兩種情況下調用相同的方法來裁剪圖片。
我在手機上有quickpic(畫廊應用程序的替代品),它具有一切功能!
private void performCrop(Uri picUri) {
try {
int aspectX = 750;
int aspectY = 1011;
Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(picUri, "image/*");
intent.putExtra("crop", "true");
intent.putExtra("scale", "true");
intent.putExtra("aspectX", aspectX);
intent.putExtra("aspectY", aspectY);
intent.putExtra("scaleUpIfNeeded", true);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(mCurrentPhotoPath)));
startActivityForResult(intent, CROP);
}
catch (ActivityNotFoundException anfe) {
String errorMessage = "Your device doesn't support the crop action!";
Toast toast = Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT);
toast.show();
}
}
一切工作正常在Android 4.2.2。 謝謝你的幫助!
謝謝你的作品太棒了! :D – Kerwan
沒問題,很高興爲你工作:) – Daveloper87
Thx很棒。但是你能解釋一下Android 4.3上的這種行爲嗎?我在Samsung s3設備的Android 4.1上也看到了這種奇怪的行爲。 – noxius