我们使用如下声明 (Manifest) 链接到应用程序的某些部分:
<activity
android:name=".some.package.SomeActivity"
android:launchMode="singleInstance"
android:exported="true">
<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="https" />
<data android:host="*.some-domain.com" />
<data android:path="/native/foo" />
</intent-filter>
</activity>
在运行 Android 12 的设备上,这突然停止工作,例如扫描包含特定 URL 的二维码会自动在默认浏览器中打开它。在 Android 12 之前,系统会在点击 https://some.domain.com/native/foo/bar/
等链接时在我们的应用中打开这些 URL。我浏览了 changelog并且无法找到任何可以解释此行为的内容(考虑到我们已经设置了 exported="true"
)。
我缺少什么以及我如何告诉系统提供我们的应用来处理那些特定的 URL?
最佳答案
更新
在测试了一些案例之后,我发现你应该将你的方案从 https
更改为非 https
字符串,例如 your_app_string
。如果你仍然想使用 https
作为你的方案,你应该检查 doordash 的 tech blog .
您应该让 android 系统可以验证您的方案。简而言之,从 android 12(api 31) 开始,您需要通过在以下位置托管数字 Assets 链接 JSON 文件来声明您的网站和 intent 过滤器之间的关联地点:
https://some.domain.com/.well-known/assetlinks.json
关于android - Android 12 中的 IntentFilter 和导出组件是否有任何(记录不详的)更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71323375/