You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android 12+免域名验证实现Deeplink跳转至App的方案咨询

问题根源

Android 12(API 31)及以上版本对http/https协议的DeepLink强制启用了应用链接(App Links)验证机制:如果Manifest中声明了http/https的Intent Filter但未完成域名验证(目标域名下无assetlinks.json验证文件),系统会默认将这类链接直接路由到浏览器,而非弹出应用选择器——这就是12+版本与低版本行为差异的核心原因。

免域名验证的可行方案

1. 改用自定义Scheme(完全绕过验证)

放弃http/https协议,改用自定义Scheme,这种方式无需任何域名验证,所有Android版本都会正常触发应用选择逻辑(若只有你的App处理该Scheme,会直接打开)。

修改MainActivity2的Intent Filter中data标签:

<activity android:name=".MainActivity2"
    android:exported="true"
    android:launchMode="standard">
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.BROWSABLE" />
        <category android:name="android.intent.category.DEFAULT" />
        <data
            android:host="papayacoders.in"
            android:scheme="papayacoder" /> <!-- 自定义Scheme -->
    </intent-filter>
</activity>

对应的链接格式为:papayacoder://papayacoders.in/xxx,这类链接不会被浏览器优先拦截。

2. 禁用自动验证,恢复应用选择器

若必须保留http/https协议,可在Intent Filter中显式设置android:autoVerify="false",告知系统不要自动执行域名验证逻辑,回到Android 12以下的行为(弹出应用选择弹窗)。

修改你的Manifest代码:

<activity android:name=".MainActivity2"
    android:exported="true"
    android:launchMode="standard">
    <!-- 给每个http/https的Intent Filter添加autoVerify="false" -->
    <intent-filter android:autoVerify="false">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.BROWSABLE" />
        <category android:name="android.intent.category.DEFAULT" />
        <data
            android:host="papayacoders.in"
            android:scheme="http" />
    </intent-filter>
    <intent-filter android:autoVerify="false">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.BROWSABLE" />
        <category android:name="android.intent.category.DEFAULT" />
        <data
            android:host="papayacoders.in"
            android:scheme="https" />
    </intent-filter>
</activity>

原理:Android 12+默认对http/https的Intent Filter启用autoVerify=true,验证失败后直接路由到浏览器;设置autoVerify=false后,系统将其视为普通DeepLink,触发应用选择流程。

关于Signal的离线行为说明

Signal的情况是因为它已完成App Links的域名验证,且系统缓存了验证结果。当设备离线时,系统会调用缓存的验证信息,因此仍能直接打开App。但该方案需要拥有目标域名的控制权(放置assetlinks.json),不适用你的场景。

内容的提问来源于stack exchange,提问作者Vipul Gupta

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 00:32:03