Intent action type ("image/jpeg") not enforced by all registered apps, which return incorrect filetypes

Viewed 82

Objective

Send an intent to open the gallery for selecting photos, show photos only, and allow multi select. Simple.

Problem

There are some apps that are registered to receive this intent, but don't appear to properly enforce the photos-only-requirement. For example, an app called "File Manager" with over 50M downloads. As a result, if I follow the approach that I was familiar with, but a user chooses File Manager to choose photos on their device, it allows them to select any file type without restriction.

What I'm asking for

Option 1: A way to prevent File Manager from being an option when I send my intent Option 2: A way to make sure File Manager only shows photos and not videos


Things I've tried

1

val intent = Intent(
        Intent.ACTION_PICK
).apply {
    type = "image/jpeg"
    putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
}

Gives me two options to receive this intent: Gallery or File Manager (the latter lets me choose videos unfortunately)


2

val intent = Intent(
        Intent.ACTION_PICK,
        MediaStore.Images.Media.EXTERNAL_CONTENT_URI
).apply {
    putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
}

Same result as 1.


3

val intent = Intent(
        Intent.ACTION_GET_CONTENT
).apply{
    type= "image/jpeg"
    putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
}

This one goes straight to the “Files” app, but allows me to go to 3rd party apps within it (including File Manager, which lets me choose videos unfortunately):


4

val intent = Intent(
        Intent.ACTION_OPEN_DOCUMENT
).apply{
    type= "image/jpeg"
    putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
}

On Android 12 with a pixel, this launches the Files app directly (successfully narrows down to just images, and doesn’t offer browsing in 3rd party apps) but on Android 10 (also pixel), it still allows me to receive the intent with File Manager, which still allows me to choose videos.


0 Answers
Related