0

在 Android11 中,我想使用该设备的默认 Cropper 并使用 Crop Intent 可能吗?

此代码在 android 11 以下工作,但不能在 android 11 startactivity 上工作,因为结果没有给出结果 ok 。我试过这段代码......

   Intent intent = new Intent("com.android.camera.action.CROP");
            intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
            intent.setType("image/*");
            List<ResolveInfo> list = mContext.getPackageManager().queryIntentActivities(intent, 0);
            int size = list.size();
            if (size == 0) {
                Toast.makeText(mContext, "Can not find image crop app", Toast.LENGTH_SHORT).show();
              
             
            } else {
                intent.setDataAndType(sourceImage, "image/*");
                intent.putExtra("aspectX", ASPECT_X);
                intent.putExtra("aspectY", ASPECT_Y);
                intent.putExtra("outputY", OUT_PUT_Y);
                intent.putExtra("outputX", OUT_PUT_X);
                intent.putExtra("scale", SCALE);
    
                //intent.putExtra("return-data", true);
                intent.putExtra(MediaStore.EXTRA_OUTPUT, destinationImage);
                selectedImageUri = destinationImage;
               
                Intent i = new Intent(intent);
                ResolveInfo res = list.get(0);
                i.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
                ((Activity) mContext).startActivityForResult(i, SELECTED_IMG_CROP);
                
}
4

0 回答 0