How can i ask for multpile MIME types with ActivityResultLauncher.GetContent()?
I'm trying to retrive from the user a file that can be both image or a pdf, using
registerForActivityResult(ActivityResultContracts.GetContent()) { file: Uri ->
......
}.launch(<mimetypes>)
I've already tried "image/*|application/pdf"
from another question's answer but it didn't work, is there any way to ask for multiple MIME types when using registerForActivityResult ?
is there any way to ask for multiple MIME types when using registerForActivityResult ?
Not directly with the current version of ActivityResultContracts.GetContent
. However, you should be able to subclass it, override createIntent()
, and from there customize the generated Intent
. You can then try adding EXTRA_MIME_TYPES
to that Intent
with a String[]
of the additional MIME types that you want.