0

I don't know how to properly phrase this question. However I'll do my best. When I'm in my phones web browser and I click a direct video link example(https://test-videos.co.uk/vids/bigbuckbunny/mp4/h264/1080/Big_Buck_Bunny_1080_10s_1MB.mp4) The browser asks if I would like to open or Download the file. I chose open and the system gives me a selection of apps I can open the file with. The problem is my app is not listed. If I highlight and share the link my app is listed. However I want it to be listed for both when I open or share.

in my manifest I added the following to the mainactivity:

    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter android:scheme="http"
            tools:ignore="AppLinkUrlError">
            <action android:name="android.intent.action.SEND"/>
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.BROWSABLE"/>
            <data android:mimeType="video/*"/>
        </intent-filter>
        <intent-filter android:scheme="http"
            tools:ignore="AppLinkUrlError">
            <action android:name="android.intent.action.SEND"/>
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <data android:mimeType="text/plain"/>
        </intent-filter>
    </activity>

2 Answers2

0

Try adding

<category android:name="android.intent.category.BROWSABLE"/>

Activities that can be safely invoked from a browser must support this category. For example, if the user is viewing a web page or an e-mail and clicks on a link in the text, the Intent generated execute that link will require the BROWSABLE category, so that only activities supporting this category will be considered as possible actions. By supporting this category, you are promising that there is nothing damaging (without user intervention) that can happen by invoking any matching Intent.

You might need to add <action android:name="android.intent.action.VIEW"/> as well (you can have more than one action in a filter) but I'm not sure if that's necessary here.

cactustictacs
  • 17,935
  • 2
  • 14
  • 25
  • I added it and no luck. any other suggestions? – John Shiveley Nov 12 '20 at 19:21
  • Did you try the ``VIEW`` action? Also if you remove the plaintext filter, does sharing still work? If it does your MIME types are probably fine - if not, you're probably getting a text URL or something through Sharing, but Opening the file needs the correct data type specification, and that's where all this can get a bit tricky (and I'm definitely not an expert!) – cactustictacs Nov 12 '20 at 19:38
  • when I add the VIEW action everything gets underlined in red. Yep I tried View action. see code I updated. – John Shiveley Nov 13 '20 at 01:14
  • If I remove plaintext it does not work. Data type could be my issue. Im using big buck bunny test video here: https://test-videos.co.uk/bigbuckbunny/mp4-h264 Don't give up on me please. I'm losing hair over this lol. Any other thoughts? – John Shiveley Nov 13 '20 at 15:24
  • Yeah sorry, I've been messing around with it for a while and I can't get anything to work. I added the link as a "Website" in the Contacts app (just in case Chrome wasn't actually calling out for apps to play a video it can handle) but no dice. I pasted in the intent filters from the Browser app code (off another answer somewhere in here!) but under Default Apps is says my test one "claims to handle no links". Honestly I don't know, sorry buddy – cactustictacs Nov 14 '20 at 23:19
0

catustictacs led me in the right direction. I was looking for a universal way to open any link in with my app. However it seems this is not possible. You must describe a data type for each server. :( below I'll show the code for my intent filter. Its a mess but it works for the sites I specified.

** If someone knows a universal way to have my app open any link please let me know. VLC player seems to be able to open with any link.

    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="https"
                android:host="test-videos.co.uk"/>
            <!--<data android:mimeType="video/*" />-->
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="https"
                android:host="test-videos.co.uk"/>
            <data android:scheme="https"
                android:host="storage.googleapis.com"/>
            <!--<data android:mimeType="text/plain" />-->
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:mimeType="video/*" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:mimeType="text/plain" />
        </intent-filter>
    </activity>