Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Deeplinking not working with multiple schemes

I am stuck with the following scenario. I defined the following deep link intent filters in the AndroidManifest.xml

Expected behavior is when I found a url of format http://​www.domain.com/a/blabla or when there is link in SMS/eMail of format domain/xyz the system should trigger my activity.

Case #1: Working fine

    <activity
        android:name=".MYActivity">
        <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="xyz"
                android:scheme="domain" />
        </intent-filter>
    </activity>

Case #2: Working fine

     <activity
        android:name=".MYActivity">
        <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="www.domain.com"
                android:pathPrefix="/a"
             />
        </intent-filter>
    </activity>

Case #3: NOT working

    <activity
        android:name=".MYActivity">
        <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="xyz"
                android:scheme="domain" />
             <data
                android:scheme="http" 
                android:host="www.domain.com"
                android:pathPrefix="/a"
             />
        </intent-filter>
    </activity>

Any suggestions/points/help is really appreciated

like image 403
prago Avatar asked Dec 05 '14 17:12

prago


2 Answers

I placed both the deeplinks in two different intent filters and it worked!!!.

like image 123
prago Avatar answered Sep 19 '22 10:09

prago


See the documentation of <data>: it states that:

All the <data> elements contained within the same <intent-filter> element contribute to the same filter.

Hence

<intent-filter>
    <data
        android:host="xyz"
        android:scheme="domain" />
    <data
        android:scheme="http" 
        android:host="www.domain.com"
        android:pathPrefix="/a" />
<intent-filter>

is interpreted equivalently as (not real code)

<intent-filter>
    <data
        android:host="xyz"
        android:scheme="domain"
        android:scheme="http" 
        android:host="www.domain.com"
        android:pathPrefix="/a" />
<intent-filter>

which clearly has some contradictions, for example host being xyz VS www.domain.com.

like image 40
TWiStErRob Avatar answered Sep 18 '22 10:09

TWiStErRob