某些设备

时间:2017-08-23 17:13:03

标签: android image crop

从图库中裁剪图像时出错。 当我使用 Moto G3 裁剪图像时,它可以正常工作。 当我使用 LG G4 裁剪相同的图像时,它不起作用,应用程序关闭并且不会产生任何错误。

如果使用 LG G4 我修剪图像并使其非常小,它可以正常工作。 怎么了?

public Intent cropImage(Uri picUri) {
    Intent cropApps = new Intent("com.android.camera.action.CROP");
    cropApps.setType("image/*");
    List<ResolveInfo> list = getContext().getPackageManager().queryIntentActivities(cropApps, 0);
    int size = list.size();
    if (size == 0) {
        Toast.makeText(getContext(), "Can not find image crop app", Toast.LENGTH_SHORT).show();
    } else {
        Toast.makeText(getContext(), "Recortar imagen", Toast.LENGTH_SHORT).show();
        ResolveInfo res = list.get(0);
        Intent cropIntent = new Intent();
        cropIntent.setClassName(res.activityInfo.packageName, res.activityInfo.name);
        cropIntent.setDataAndType(picUri, "image/*");

        cropIntent.putExtra("outputX", 1080);
        cropIntent.putExtra("outputY", 1920);
        cropIntent.putExtra("aspectX", 1);
        cropIntent.putExtra("aspectY", 1);
        cropIntent.putExtra("scale", true);
        cropIntent.putExtra("return-data", true);
        return cropIntent;
    }
    return null;
}

0 个答案:

没有答案