I am trying to add multi select image feature in my android app. This is how I am trying to do it
val gallery = Intent( Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI )
gallery.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
startActivityForResult(gallery, ACTION_REQUEST_GALLERY)
In emulator with OS version 9, 10 it works perfectly fine. But when I test it on Oppo F5 with OS version 7.1.1 then it doesnt work.
But if I add gallery.setAction(Intent.ACTION_GET_CONTENT) then I can select multiple images on all devices but problem is that this method show images in very weird way and its not that much user friendly.
Any help will be highly apprecited, thanks
But when I test it on Oppo F5 with OS version 7.1.1 then it doesnt work.
ACTION_PICK is not documented to support EXTRA_ALLOW_MULTIPLE. Specifically:
The documentation for ACTION_PICK does not mention any supported extras
The documentation for EXTRA_ALLOW_MULTIPLE only mentions ACTION_GET_CONTENT and ACTION_OPEN_DOCUMENT
Hence, you should not assume that any ACTION_PICK activity will do anything in response to your EXTRA_ALLOW_MULTIPLE extra.
this method show images in very weird way and its not that much user friendly.
There are over 26,000 Android device models. There will be hundreds of different pre-installed apps for ACTION_PICK and ACTION_GET_CONTENT that might handle your request. How any of them render their UI, and how any of them react to unexpected extras, is up to their developers, not you or I. You seem to think that ACTION_PICK always results in one form of UI; that is incorrect.
Any help will be highly apprecited, thanks
Either:
Use ACTION_PICK and live with fact that EXTRA_ALLOW_MULTIPLE may be ignored, or
Use ACTION_GET_CONTENT/ACTION_OPEN_DOCUMENT, or
Use the MediaStore APIs directly and render your own image selector, or
Use one of the few dozen libraries that implement an image selector
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With