Android深层链接省略了某些网址

Aay*_*kur 9 android deep-linking android-manifest

我已成功实现了对我的应用程序的深层链接,但我遇到了问题.

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

PLN*_*ech 10

Android的深层链接机制不提供一种方式来明确排除在Android深度链接机制的一些网址:您可以要么明确包括与路径android:path,包括匹配的前缀路径android:pathPrefix或匹配使用通配符android:pathPattern,您可以使用*.*.

在您的情况下,您必须使用"/"并使用您的应用程序(包括您的主页)打开您网站的每个链接,或者让每个深层链接共享一个共同的前缀.

您还可以查看airbnb的DeepLinkDispatch库,它似乎允许排除特定的URL.


小智 5

如果我正确理解您的问题,您希望从特定的 URL 列表中排除特定的 URL。你尝试的是一个很好的方法来做到这一点。

android:pathPattern 不理解你所说的复杂的正则表达式模式。

我认为解决您的问题的唯一方法是更改​​您要省略的 URL。更改主机或URL的一部分,或更改名称example.com,比方说,example2.com/hello/redirect/