【发布时间】:2017-05-16 07:02:43
【问题描述】:
我已成功实现到我的应用的深层链接,但我遇到了一个问题。
<intent-filter android:autoVerify="true">
<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.com"
android:scheme="https"/>
</intent-filter>
此意图过滤器处理所有链接,但我不想捕获某个 url,即
https://www.example.com/hello/redirect/
到目前为止我尝试了什么:
我尝试输入所有我想手动捕获的 URL
<data
android:host="*example.com"
android:scheme="https"
android:pathPrefix="/m/">
<data
android:host="*example.com"
android:scheme="https"
android:pathPrefix="/c/">
<data
android:host="*example.com"
android:scheme="https"
android:pathPrefix="/p/">
...
然后我的主页 URL https://www.example.com 不起作用。
如果我使用
android:pathPrefix="/"
然后这将再次开始捕获所有 URL,包括我想省略的 URL。
我也尝试过使用android:pathPattern,但它无法理解像^((?!redirect).)*$ 这样的复杂正则表达式,当我在字符串中尝试它时效果很好。
有人知道我怎样才能省略某些网址吗?
更新:
按照@PLNech here 的建议,我添加了所有需要使用android:pathPrefix 捕获的URL,并使用android:path: "/" 捕获我主页的URL,即https://www.example.com/
<data
android:host="*.example.com"
android:scheme="https"
android:path="/"/>
<data
android:host="*example.com"
android:scheme="https"
android:pathPrefix="/m/">
<data
android:host="*example.com"
android:scheme="https"
android:pathPrefix="/c/">
<data
android:host="*example.com"
android:scheme="https"
android:pathPrefix="/p/">
【问题讨论】:
标签: android android-manifest deep-linking