android - Android 深层链接路径、pathPrefix 或 pathPattern 不起作用
问题描述
我正在尝试使 Android 深度链接仅适用于特定的 url,例如:
所以http://books.com/about一直链接到网页
我的作品中的此配置AndroidManifest.xml
并在我的应用程序中打开正确的页面。问题是这与books.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:scheme="@string/custom_url_scheme" />
<data android:scheme="https" android:host="books.com" />
</intent-filter>
当我将数据部分更改为:
<data android:scheme="https" android:host="books.com" android:path="/book/nice-book-1" />
或者
<data android:scheme="https" android:host="books.com" android:pathPrefix="/book" />
或者
<data android:scheme="https" android:host="books.com" android:pathPattern="/book/..*" />
只匹配/book
一个蛞蝓,它不起作用。
我已经在 Stackoverflow 上找到了许多类似的问题,但它们要么已经过时,要么无法处理 url 与 slug 一起使用的情况。
在仅将几个 url 与 slug 匹配时,是否有人遇到过同样的问题?
解决方案
我花了很长时间才弄清楚这一点。所以我会回答我自己的问题以节省其他人宝贵的时间。
事实证明,当通过 Android Studio 在设备上运行 Android 应用程序时
<data android:scheme="https" android:host="books.com" />
是唯一可行的途径。
使用时:
<data android:scheme="https" android:host="books.com" android:path="/book/nice-book-1" />
或者
<data android:scheme="https" android:host="books.com" android:pathPrefix="/book" />
这些仅在您的设备上使用签名版本的应用程序时才有效。这可能是因为您assetlinks.json
有一个sha256_cert_fingerprints
只有在使用签名的应用程序时才能验证的内容。
推荐阅读
- c# - DataGridComboBoxColumn 初始值不显示
- byte-buddy - 无法用 ByteBuddy 重新定义“java.io.ObjectInputStream”?
- python-3.6 - 如何从'list form txt file'导入列表?
- textmatebundles - 匹配 Textmate 包文件类型部分中的完整文件名
- android - 如何在放置在平面上时为 ModelRenderable 设置动画?
- pytorch - 损失减少但f1分数保持不变
- http - IIS 中的 HTTP 重写规则未激活
- ruby - 数组的未定义方法“过滤器”
- html - 使用粘性部分实现三部分标题
- google-apps-script - Script 'setValues' method interprets strings as numbers in cells