'How to choose multiple files from storage with chosen more than one extension?

I would like to choose files from storage but with chosen extensions(images, and pdf) but also it has to allow to choose more than one. When I want to choose one I use:

  val contentSelectionIntent = Intent(Intent.ACTION_GET_CONTENT)
    contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE)
    contentSelectionIntent.type = "*/*"
    val mimeTypes = arrayOf("image/*", "application/pdf")
    contentSelectionIntent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes)
    val chooserIntent = Intent(Intent.ACTION_CHOOSER)
    chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent)
    chooserIntent.putExtra(Intent.EXTRA_TITLE, "File chooser")
    startActivityForResult(chooserIntent, 2)

but how about multiple files? When I want to add contentSelectionIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true) to this it doesn't work.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source