android - Android 12 中的 IntentFilter 和导出组件是否有任何(记录不详的)更改?

标签 android android-intent intentfilter android-12

我们使用如下声明 (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

official doc reference here

关于android - Android 12 中的 IntentFilter 和导出组件是否有任何(记录不详的)更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71323375/

相关文章:

Android 在连接到 USB 设备时禁用默认应用程序选择提示

android - 当前 ViewAnimator 的新替代品是什么?

android - 使用带有 ionic 和电容器的 https 加载 webview

android - 广告叠加层需要在 intent extras 中使用 useClientJar 标志。

android - Google Pay UPI 集成在 android 中不起作用

Android:Intent-Filter 是如何工作的?

android - 如何创建半椭圆形(弯曲一条线)

java - 我可以覆盖外部库中的方法吗?

Android小部件通过 Intent 将数据发送到onRecive

android - android sdk中网络事件的 Intent 操作