Giter VIP home page Giter VIP logo

Comments (8)

LloydBlv avatar LloydBlv commented on July 19, 2024 1

@ArthurHub You were right! I couldn't reproduce the issue using your way of selecting files, thank you so much!

from android-image-cropper.

ArthurHub avatar ArthurHub commented on July 19, 2024

Looks like it has something to do with KitKat documents provider, there are a few relevant question on SO: example1, example2, example3.

Is it 100% reproducible?
Do you experience it on KitKat?
Did you use the "Documents" source for getting image for cropping?
What was the source of the image within the "Documents" UI? (Recent/Drive/Downloads/Gallery/etc.)

from android-image-cropper.

LloydBlv avatar LloydBlv commented on July 19, 2024

@ArthurHub I'm on android 6.0.1, And yes for some images it's 100% reproducible, The source of images was Recents, and i'm using com.mlsdev.rximagepicker:library as image picker library, I'm wondering that there's no problem before cropping the image and CropImageView loads the URI properly but just after pressing crop it throws that exception!

from android-image-cropper.

ArthurHub avatar ArthurHub commented on July 19, 2024

100% reproducible is excellent, we can make sure we found a solution then.

I think this library is missing a "persistable" permissions request (relevant doc):

getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);

can you try adding it before setting it for cropping.

from android-image-cropper.

LloydBlv avatar LloydBlv commented on July 19, 2024

@ArthurHub Sure! let me give it a try! thanks

from android-image-cropper.

LloydBlv avatar LloydBlv commented on July 19, 2024

@ArthurHub It didn't help added another exception:
No persistable permission grants found for UID 10240 and Uri 0 @ content://com.android.providers.media.documents/document/image:74085

from android-image-cropper.

ArthurHub avatar ArthurHub commented on July 19, 2024

Looks like there are a few things missing in the image pick intent creation, this SO questions cover this problem exactly.

looking at rximagepicker it doesn't use the "proper" intent for KitKat and above API (source)

It should be more like this one:

Intent intent;
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
    intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
    intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
    intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
}else{
    intent = new Intent(Intent.ACTION_GET_CONTENT);
}
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setType("image/*");
startActivityForResult(Intent.createChooser(intent, getResources().getString(R.string.form_pick_photos)), REQUEST_PICK_PHOTO);

Try using your own code to pick the image from the library and see if it works

P.S. a quick look at rximagepicker didn't impress me, there may be better libraries or just write a simple picker like I use in this library sample (source).

from android-image-cropper.

LloydBlv avatar LloydBlv commented on July 19, 2024

@ArthurHub Thanks,i'll try your solution to pickup images and let you know the results!

from android-image-cropper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.