Search code examples
androidandroid-intentandroid-6.0-marshmallowandroid-filterandroid-intent-chooser

My app won't show up on the chooser dialog for android.intent.action.VIEW with mime type video/* only on Marshmallow


Basically when an app shares a video url my app is supposed to show up on the list but it doesn't. Neither does MXPlayer but the Google Photos media player shows up fine as well as allcast (which had a recent release to fix this).

I wrote a quick app to test this issue, here are my manifest filters:

<intent-filter>
    <action android:name="android.intent.action.MAIN"/>
    <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>

<intent-filter>
    <category android:name="android.intent.category.DEFAULT"/>
    <data android:mimeType="text/plain"/>
    <data android:mimeType="video/*"/>
    <data android:mimeType="audio/*"/>
    <data android:mimeType="image/*"/>
    <action android:name="android.intent.action.SEND"/>
</intent-filter>

<intent-filter>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:mimeType="video/*" android:scheme="http"/>
    <data android:mimeType="audio/*" android:scheme="http"/>
    <data android:mimeType="image/*" android:scheme="http"/>
    <data android:mimeType="video/*" android:scheme="https"/>
    <data android:mimeType="audio/*" android:scheme="https"/>
    <data android:mimeType="image/*" android:scheme="https"/>
    <data android:mimeType="video/*" android:scheme="file"/>
    <data android:mimeType="audio/*" android:scheme="file"/>
    <data android:mimeType="image/*" android:scheme="file"/>
    <action android:name="android.intent.action.VIEW"/>
</intent-filter>

<intent-filter>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:host="*" android:pathPattern=".*\\.mp4" android:scheme="http"/>
    <action android:name="android.intent.action.VIEW"/>
</intent-filter>

And this is the code to reproduce the issue:

Intent intent = new Intent("android.intent.action.VIEW");
intent.setDataAndType(Uri.parse("http://media.w3.org/2010/05/sintel/trailer.mp4"),"video/*");
startActivity(intent);

This is only an issue on Marshmallow.

EDIT: I should add that not all Marshmallow devices do this. It took me a long time to reproduce it from the first time I heard about it and one day it just started happening on my Nexus 5. My 6P won't reproduce this.

EDIT: I added some debugging code prior to startActivity. Basically I'm asking the package manager to give me the intent activities that can handle that intent and I get back the exact same list I see on the dialog.

PackageManager manager = getBaseContext().getPackageManager();
                List<ResolveInfo> infos = manager.queryIntentActivities(intent, 0);
                if (infos.size() > 0) {
                    //THE INFOS LIST HAS THE 3 APPS THAT IT SHOWS BUT MINE IS MISSING
                }else{

                }

EDIT: I figured adding screenshots might make it more clear.

This is on my Nexus 5 with 6.0.1, the list is fully expanded This is on my Nexus 5 with 6.0.1, the list is fully expanded

This is on my Nexus 4 with 5.1.1, list also fully expanded This is on my Nexus 4 with 5.1.1, list also fully expanded

Both phones have pretty much the exact same apps.


Solution

  • Fixed it! All I had to do was remove <category android:name="android.intent.category.BROWSABLE"/>