Reputation: 934
I have a reasonably simple question which I cannot seem to find the solution to. I have an Android app with multiple activities. I want to form specific deep links to specific activities as well as direct all other deep links to a "catch-all" type activity.
This is my manifest:
<activity
android:name=".views.activity1">
<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="domain"
android:host="specificPlace" />
</intent-filter>
</activity>
<activity
android:name=".views.activity2">
<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="domain"
android:host="*" />
</intent-filter>
</activity>
So what I want is the following:
domain://specificPlace
-> deep links to activity1.
domain://
-> deep links to activity2
domain://random
-> deep links to activity2
domain://somewhereElse
-> deep links to activity2
Right now domain:// anything is resolving to activity2.
Any help is appreciated, thanks in advance!
Upvotes: 1
Views: 1424
Reputation: 54204
The <intent-filter>
element supports an integer priority
attribute. By default, this has a value of 0
, so you could set a negative priority on the "catch-all" filter to make sure it runs after all the others:
<intent-filter android:priority="-1">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:scheme="domain"
android:host="*" />
</intent-filter>
I have not tried this myself, but it seems like it should work. The part I'm not sure about is whether or not the priority
attribute handles negative values. If it does not, you could instead put a positive priority on all of the non-"catch-all" filters:
<intent-filter android:priority="1">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:scheme="domain"
android:host="specificPlace" />
</intent-filter>
Upvotes: 5