xan
xan

Reputation: 4696

Deeplink intent filter to a particular pathPrefix?

I've enabled deep linking on my android app and it's working fine.

However, I want the intent-filter to listen to a particular pathPrefix only i.e. http(s)://(www.)mydomain.com/e and not any other pathPrefix.

Is this possible? I'm attaching my intent-filter code in AndroidManifest.xml

<intent-filter android:label="My App Name">
<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="/e" />
            <data android:scheme="http"
                android:host="mydomain.com"
                android:pathPrefix="/e" />
            <data android:scheme="https"
                android:host="www.mydomain.com"
                android:pathPrefix="/e" />
            <data android:scheme="https"
                android:host="mydomain.com"
                android:pathPrefix="/e" />
</intent-filter> 

Upvotes: 7

Views: 3853

Answers (2)

Andrei Tudor Diaconu
Andrei Tudor Diaconu

Reputation: 2247

Since the code pasted by you is good for that pathPrefix, I'm guessing you want to catch only http(s)://(www.)mydomain.com/e and nothing else?
If this is the case, use path instead of pathPrefix like so.

<intent-filter android:label="My App Name">
<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:path="/e" />
            <data android:scheme="http"
                android:host="mydomain.com"
                android:path="/e" />
            <data android:scheme="https"
                android:host="www.mydomain.com"
                android:path="/e" />
            <data android:scheme="https"
                android:host="mydomain.com"
                android:path="/e" />
</intent-filter> 

Upvotes: 0

Mimmo Grottoli
Mimmo Grottoli

Reputation: 5773

With that piece of manifest, you're telling to your device to launch the Activity that contains that intent filter with all url that have

  1. http or https as protocol
  2. www.mydomain.com or mydomain.com as host
  3. /e as prefix of the path

Since the question is related to pathPrefix, your activity will handle all the urls whose path has a /e at the beginning. For example:

  • http(s)://(www.)mydomain.com/e - MATCH
  • http(s)://(www.)mydomain.com/eXXX - MATCH
  • http(s)://(www.)mydomain.com/e/a - MATCH
  • http(s)://(www.)mydomain.com/eXXX/a - MATCH
  • http(s)://(www.)mydomain.com/e?a=b - MATCH
  • http(s)://(www.)mydomain.com/Xe - DON'T MATCH
  • http(s)://(www.)mydomain.com/X/e?a=b - DON'T MATCH

Upvotes: 4

Related Questions