android 第三方裁剪,Android裁剪意向不适用于系统图库应用程序,但适用于第三方应用程序...

我尝试从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;

}

}

?我错过了什么吗?

?感谢您的关注!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值