Amit Bhandari
Amit Bhandari

Reputation: 3134

Intent filter for dynamic links is not working as expected

I have following intent filter set up for detecting links to open in our app.

            <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="share.example.tv"
                    android:pathPrefix="/"
                    android:scheme="https" />
                <data
                    android:host="example.tv"
                    android:pathPrefix="/u"
                    android:scheme="https" />
            </intent-filter>

I want my app to open below 2 links

  1. https://share.example.tv/tv34gh
  2. https://example.tv/u/some-user-name

But my app is showing up for these links as well

https://example.tv/anything/literally-anything

Upvotes: 0

Views: 851

Answers (1)

Amit Bhandari
Amit Bhandari

Reputation: 3134

If I separate both of the links in different intent-filters for same activity like below

            <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="share.example.tv"
                    android:pathPrefix="/"
                    android:scheme="https" />
            </intent-filter>

            <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="example.tv"
                    android:pathPrefix="/u"
                    android:scheme="https" />
            </intent-filter>

This works but I don't know why.

Upvotes: 1

Related Questions