简体   繁体   中英

No Activity found to handle Intent : android.intent.action.EDIT

I want to open crop intent after picking image or capturing through camera.

Gallery:

Intent cropIntent = new Intent("android.intent.action.EDIT");
        cropIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        cropIntent.setDataAndType(file, "image/*");
        cropIntent.putExtra("crop", "true");
        cropIntent.putExtra("aspectX", 1);
        cropIntent.putExtra("aspectY", 1);
        cropIntent.putExtra("outputX", 256);
        cropIntent.putExtra("outputY", 256);
        cropIntent.putExtra("return-data", true);
        startActivityForResult(cropIntent, CROP_PIC);

Camera:

  Intent cropIntent = new Intent("android.intent.action.EDIT");
        cropIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        File file = new File(filePath);
        Log.i("checker", "does " + file.getAbsolutePath() + " exist ?" + file.exists());
        Uri uri = Uri.fromFile(file);
        cropIntent.setDataAndType(uri, "image/*");
        cropIntent.putExtra("crop", "true");
        cropIntent.putExtra("aspectX", 1);
        cropIntent.putExtra("aspectY", 1);
        cropIntent.putExtra("outputX", 256);
        cropIntent.putExtra("outputY", 256);
        cropIntent.putExtra("return-data", true);
        startActivityForResult(cropIntent, CROP_PIC);

It works on most of devices, but on Galaxy Tab A (Android 11.0) while opening edit intent it gives exception:

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.EDIT dat=content://media/external/images/media/356 typ=image/* flg=0x1 (has extras) }

I am using This edit intent though crop intent would suffice,because on Galaxy Tab A when recieving image through gallery, the image is rotated 90 degree counter clockwise dont know why. so using edit intent and its not working either.

You can use the Image cropper library please review it and use it.

https://github.com/ArthurHub/Android-Image-Cropper

https://github.com/Yalantis/uCrop

I hope it's helpful to you!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM