添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Intent.EXTRA_ALLOW_MULTIPLE not working with Intent.ACTION_PICK when I test on Oppo (OS Version 7.1.1) in android

Ask Question

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

see here also although the answer below is correct for this question : stackoverflow.com/a/70828005/3904109 – DragonFire Jan 24, 2022 at 1:23

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

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.

  •