我尝试从sdcard中选择一个图像,然后进行裁剪.
ACTION_PICK没问题,但是当我调用ACTION_CROP时,我的系统图库应用程序(我称为A)无法执行操作,而另一个应用程序(B)可以执行该操作.
?我尝试了以下情况:
?1 /按A挑选,然后按A裁切=>选择确定,作物歉收
?2 /按B挑选,然后按A裁切=>与第一种情况相同.
?3 /由A选择,然后由B裁切=>一切都好.
?4 /按B挑选,然后按B裁切=>一切都好.
?所以我的临时结论是:我的系统应用程序无法使用我的代码进行裁剪操作(可能是我忘记了一些东西).这是我的代码:
?ACTION_PICK:
public Intent galleryIntent() {
Intent galleryIntent = new Intent(Intent.ACTION_PICK);
galleryIntent.setType("image/*");
galleryIntent.putExtra("return-data", true);
return galleryIntent;
}
?ACTION_CROP:
public Intent cropIntent(Uri inUri, int outputX, int outputY,
boolean isScale) {
Intent cropIntent = new Intent("com.android.camera.action.CROP");
cropIntent.setDataAndType(inUri, "image/*");
cropIntent.putExtra("crop", "true");
cropIntent.putExtra("aspectX", outputX);
cropIntent.putExtra("aspectY", outputY);
cropIntent.putExtra("outputX", outputX);
cropIntent.putExtra("outputY", outputY);
cropIntent.putExtra("scale", isScale);
cropIntent.putExtra("return-data", true);
return cropIntent;
}
?我的onActivityResult方法
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
switch (requestCode) {
case REQUEST_CODE_GALLERY:
imageUri = data.getData();
startActivityForResult(cropIntent(imageUri,
500, 500, true), REQUEST_CODE_CROP);
break;
case REQUEST_CODE_CROP:
Bundle extras = data.getExtras();
Bitmap tempBitmap = extras.getParcelable("data");
imgvMain.setImageBitmap(null);
imgvMain.setImageBitmap(tempBitmap);
break;
}
} else {
imageUri = null;
}
}
?我错过了什么吗?
?感谢您的关注!