Deeplink intent filter to a particular pathPrefix?

时间:2015-07-31 20:55:38

标签: android deep-linking

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> 

2 个答案:

答案 0 :(得分:2)

使用该清单,您告诉您的设备启动包含具有

所有网址的意图过滤器的活动
  1. http或https as protocol
  2. www.mydomain.com或mydomain.com作为主持人
  3. / e作为路径的前缀
  4. 由于该问题与pathPrefix有关,因此您的活动将处理其路径在开头具有/ e的所有网址。例如:

    • 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 - 不要匹配
    • http(s)://(www。)mydomain.com/X/e?a=b - 请勿搭配

答案 1 :(得分:0)

由于您粘贴的代码对pathPrefix有好处,我猜您只想抓住http(s)://(www.)mydomain.com/e而没有其他内容?
如果是这种情况,请使用path代替pathPrefix

<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>