简体   繁体   English

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

[英]Crop functionality is working on marshmallow or above but do not work below marshmallow

Image is crop and see successfully in List in marshmallow and above but not working below marshmallow. 图片已裁剪,可以在棉花糖及以上的列表中成功查看,但在棉花糖以下则无法正常工作。 I think if we pick google photo for crop than it is working in other scenario its nont working. 我认为,如果我们选择谷歌照片进行裁剪,而不是在其他情况下可以正常工作。

Also in my situation runtime permission is already provided. 同样在我的情况下,已经提供了运行时权限。

Code to click image from camera 代码以单击相机中的图像

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;
        }
    }
}

Image is crop and see successfully in List in marshmallow 图片已裁剪,可在棉花糖列表中成功查看

No, it does not. 不,不是的。 It happens to work on the one device that you tested. 它恰好在您测试的一台设备上工作。 Android does not have a CROP Intent . Android没有CROP Intent A few devices might, out of the thousands of devices on the market. 市场上成千上万的设备中可能只有少数设备。

There are many image cropping libraries available for Android . 有许多可用于Android的图像裁剪库 Use one. 使用一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 showInputMethodPicker 在 Marshmallow 以上的设备上不起作用? - showInputMethodPicker not working on devices above Marshmallow? 通话记录不适用于棉花糖及以上版本 - Call recording not working in marshmallow and above GoogleApiClient无法在棉花糖及以上设备中使用吗? - GoogleApiClient is not working in marshmallow and above devices? onReceivedError 在 android Marshmallow 及以下版本中不起作用 - onReceivedError not working in android Marshmallow and below 相机许可在棉花糖及以上设备上不起作用并崩溃 - Camera permission is not working on Marshmallow and above devices and crashes Marshmallow权限不适用于低于23的TargetVersion - Marshmallow Permissions not working for TargetVersion below 23 在棉花糖版本以下无休止地滚动 - Endless scrolling in not working in below marshmallow version 棉花糖及以下api显示循环依赖项错误。 相同的布局在棉花糖上也能正常工作 - Marshmallow and below api's showing circular dependencies error. Same layout works fine above marshmallow Java邮件在棉花糖及更高版本上失败,但在棒棒糖及更高版本上成功 - Java mail fails on Marshmallow and above, but succeeds on Lollipop and below javax.mail在棉花糖或更高版本的系统上不起作用 - javax.mail isn't working on Marshmallow or above systems
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM