1

From file chooser I want to allow choose only pdf and images, is it possible to do in Android? I tried do same things from another answer, but I don't know why, file manager allow choose any file.

 override fun createIntent(context: Context, input: Array<String>?): Intent {
        val mimeTypes = arrayListOf("image/*", "application/pdf")
        return Intent().apply {
            type = "*/*"
            action = Intent.ACTION_OPEN_DOCUMENT
            addCategory(Intent.CATEGORY_OPENABLE)
            putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes)
        }
    }
crtrn
  • 31
  • 3

1 Answers1

0

This is a bit late but I am looking for the same solution currently and I found this: Passing Multiple Mime Types to ActivityResultLauncher.launch() It solved my problem like a charm. Hope it's helpful for people ran into this problem in the future.

Shaw
  • 1