我正在尝试创建一个深度链接,以匹配指定域上的URL,而不是任何子域上的URL。我的意向过滤器<data />
条目如下所示:
<data
android:host="example.com"
android:pathPrefix="/somepath"
android:scheme="https" />
这很好用,并且如我所期望的那样将URL与https://example.com/somepath
相匹配。然而,我也有一些看起来像https://subdomain.example.com/somepath
的URL,我不想匹配。这些也会被该数据条目拾取!
我想在主机上严格匹配,不包括任何子域。这在安卓系统中可能吗?
无法更改任何一组链接的URL方案。
正如我在文档中看到的,您的配置将与子域不匹配。
如果你想接受所有子域,你必须在你的主机前使用一个星号(*
(字符,如下所示:*.example.com
。
因此,答案是:example.com
不会与任何像subdomain.example.com
这样的子域匹配
我已经创建了和具有以下意图过滤器的活动
<intent-filter>
<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:pathPrefix="/somepath"
android:scheme="https" />
</intent-filter>
这将在浏览器窗口中打开test.example.com:
adb shell am start -a android.intent.action.VIEW -d "https://test.example.com/somepath/test"
这打开了我的应用程序:
adb shell am start -a android.intent.action.VIEW -d "https://example.com/somepath/test"