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

标签 android

我正在尝试创建一个深层链接来匹配特定域上的 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/

相关文章:

android - Paypal 手机SDK : Authorize a token returned from SetExpressCheckout method

android - 从 Python-Django 启动 Android 模拟器

Android: AnimationDrawable 转换错误

Android 停止查找 BLE 设备 : onClientRegistered() - status=133 clientIf=0

android - 从 Android Gradle 访问 Azure DevOps 变量

java - 列出 Android 中所有已保存的闹钟

java - 返回主要 Activity

java - 如何以编程方式将数据写入 JSON 文件然后保存?

java - 在 com.android.build.gradle.internal.dsl.BaseAppModuleExtension 类型的对象上找不到参数 [26] 的方法 ImplementationSdkVersion()

android - Android Studio 中的 Gradle 无法解析 JCenter 中的库