An SO User
An SO User

Reputation: 24998

Listening to YouTube links using intent filter

I am trying to make my app listen for YouTube links much like how how YouTube app does. I have an activity with the following intent filter:

<activity android:name=".YoutubeLinkActivity" android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data android:scheme="http" android:host="youtube.com"/>    
            </intent-filter>
</activity>  

However, the app that opens up is the default YouTube app rather than mine. I tried the same intent filter for other host, too. In that case, the browser just goes to the next page rather than firing up my app.

What needs to change here?

Upvotes: 0

Views: 769

Answers (1)

Sufian
Sufian

Reputation: 6555

I faced similar issue and interestingly it was working fine in Android 2.3.7.

To make it run on JB and above, I added android:pathPrefix="" to my <data> tag. So my <intent-filter> looked like:

<intent-filter>
    <action android:name="android.intent.action.VIEW"/>

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

    <data
        android:host="android.app.myWeb.pk"
        android:pathPrefix=""
        android:scheme="http"/>
    <data
        android:host="android.app.myWeb.pk"
        android:pathPrefix=""
        android:scheme="https"/>
</intent-filter>

Upvotes: 1

Related Questions