gpt4 book ai didi

android - 注册不包含子域的 Android 深层链接路径

转载 作者:行者123 更新时间:2023-12-04 13:36:52 25 4
gpt4 key购买 nike

我正在尝试创建一个深层链接来匹配特定域上的 URL,而不是任何子域上的 URL。我的 Intent 过滤器 <data />条目如下所示:

<data
android:host="example.com"
android:pathPrefix="/somepath"
android:scheme="https" />

这可以正常工作,并且将 URL 与 https://example.com/somepath 匹配正如我所料。但是,我也有一些看起来像 https://subdomain.example.com/somepath 的 URL。我不想匹配。这些也被该数据条目拾取!

我想在主机上严格匹配,不包括任何子域。这在Android中可能吗?

无法更改任一组链接的 URL 方案。

最佳答案

正如我在 documentation 中看到的那样,您的配置将与子域不匹配。

如果您想接受所有子域,您必须在主机之前使用星号 (*) 字符,如下所示:*.example.com .

所以,答案是:example.com不会与任何子域匹配,例如 subdomain.example.com
我已经使用以下 Intent 过滤器创建了 Activity

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

关于android - 注册不包含子域的 Android 深层链接路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61270687/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com