我可以在我的Manifest中的intent-filter中使用以下过滤器成功实现app的深层链接:
<data android:host="myhost.com"
android:pathPrefix="/v"
android:scheme="http" />
Run Code Online (Sandbox Code Playgroud)
例如.我的网址是:
http://myhost.com/v/login1.php?id=123&name=abc&type=a
http://myhost.com/v/login1.php?id=123&name=abc&type=b
Run Code Online (Sandbox Code Playgroud)
我想排除
http://myhost.com/v/login1.php?id=123&name=abc&type=c
Run Code Online (Sandbox Code Playgroud)
现在我想要排除几个具有相同前缀的Url.是否可能或我是否需要明确指定所有网址android:path?如果是这样,如何处理查询参数的值?
我已成功实现了对我的应用程序的深层链接,但我遇到了问题.
<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>
Run Code Online (Sandbox Code Playgroud)
此意图过滤器处理所有链接,但我不想捕获某个URL即ie
https://www.example.com/hello/redirect/
Run Code Online (Sandbox Code Playgroud)
到目前为止我尝试了什么:
我尝试输入我想要手动捕获的所有网址
<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/">
...
Run Code Online (Sandbox Code Playgroud)
但是我的主页网址https://www.example.com不起作用.
如果我使用
android:pathPrefix="/"
Run Code Online (Sandbox Code Playgroud)
然后这将开始再次捕获所有URL,包括我想省略的URL.
我也尝试过使用android:pathPattern,但它无法理解这样复杂的正则表达式^((?!redirect).)*$,当我在字符串和所有字符串中尝试它时,它可以正常工作.
有谁知道如何省略某些网址?
更新:
正如@PLNech 在这里建议的那样,我添加了我需要捕获的所有URL android:pathPrefix并用于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/">
Run Code Online (Sandbox Code Playgroud)