Android 作物功能适用于棉花糖或以上,但不适用于棉花糖以下

Android 作物功能适用于棉花糖或以上,但不适用于棉花糖以下,android,android-intent,android-crop,Android,Android Intent,Android Crop,图像已裁剪并在棉花糖及以上的列表中成功查看,但在棉花糖以下的列表中不工作。我认为,如果我们选择谷歌照片作为crop,那么它在其他场景中的效果会更好 在我的情况下,已经提供了运行时权限 从相机单击图像的代码 Uri fileUri; Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File file = new File(getExternalCacheDir(), String.valueOf(Syste

图像已裁剪并在棉花糖及以上的列表中成功查看,但在棉花糖以下的列表中不工作。我认为,如果我们选择谷歌照片作为crop,那么它在其他场景中的效果会更好

在我的情况下,已经提供了运行时权限

从相机单击图像的代码

Uri fileUri;

    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    File file = new File(getExternalCacheDir(), String.valueOf(System.currentTimeMillis()) + ".jpg");
    fileUri = Uri.fromFile(file);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
    startActivityForResult(intent, 501);

@Override
protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {

        case 501:
            isFromOneActivityToAnother = true;
            ImageCropFunction();
            //startCropImageActivity(fileUri);
            break;

        case 502:
            uriImageListForServer.add(getImageContentUri(getApplicationContext(), new File((fileUri + "").substring(7, (fileUri + "").length()))));
            break;
    }
}

public void ImageCropFunction() {
    try {
        isFromOneActivityToAnother = true;
        Intent CropIntent = new Intent("com.android.camera.action.CROP");
        CropIntent.setDataAndType(fileUri, "image/*");
        CropIntent.putExtra("crop", "true");
        CropIntent.putExtra("outputX", 2048);
        CropIntent.putExtra("outputY", 2048);
        CropIntent.putExtra("scaleUpIfNeeded", true);
        CropIntent.putExtra("return-data", true);

        startActivityForResult(CropIntent, 502);
    } catch (ActivityNotFoundException e) {

    }
}

public static Uri getImageContentUri(Context context, File imageFile) {
    String filePath = imageFile.getAbsolutePath();
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
            new String[]{MediaStore.Images.Media._ID},
            MediaStore.Images.Media.DATA + "=? ",
            new String[]{filePath}, null);
    if (cursor != null && cursor.moveToFirst()) {
        int id = cursor.getInt(cursor.getColumnIndex(MediaStore.MediaColumns._ID));
        cursor.close();
        return Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "" + id);
    } else {
        if (imageFile.exists()) {
            ContentValues values = new ContentValues();
            values.put(MediaStore.Images.Media.DATA, filePath);
            return context.getContentResolver().insert(
                    MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
        } else {
            return null;
        }
    }
}
图像被裁剪并在棉花糖列表中成功查看

不,没有。它恰好在您测试的一台设备上工作。Android没有
CROP
Intent
。在市场上成千上万的设备中,可能会有一些设备

有很多。使用一个。

请参阅