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

Android 13含特定文本DeepLink跳转APP问题求助

解决方案

你当前的intent-filter只明确匹配了/account路径,所以含-p-的商品链接根本不会被应用捕获,自然跳转至浏览器。要实现仅匹配含-p-的链接,需修改data标签的路径匹配规则,以下是可行方案:

方案1:使用pathPattern(兼容全Android版本)

替换原有<data android:path="/account" />,改为匹配路径中包含-p-的规则:

<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data android:scheme="http" />
    <data android:scheme="https" />
    <data android:host="*.example.com" />
    <data android:host="example.com" />
    <!-- 匹配任意位置包含-p-的路径 -->
    <data android:pathPattern=".*-p-.*" />
</intent-filter>

.*代表任意字符序列,.*-p-.*可匹配路径中任何位置带有-p-的链接,完全覆盖你给出的商品链接格式。

方案2:使用pathAdvancedPattern(仅Android 12+)

若只针对Android 12(API 31)及以上版本,可使用更灵活的正则匹配:

<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />

    <data android:scheme="http" />
    <data android:scheme="https" />
    <data android:host="*.example.com" />
    <data android:host="example.com" />
    <!-- 正则匹配含-p-的路径 -->
    <data android:pathAdvancedPattern=".*-p-.*" />
</intent-filter>

注意:pathAdvancedPattern是Android 12新增特性,低版本系统不支持,需兼容旧版本时优先选方案1。

关键注意事项

  • 确保autoVerify="true"生效:需在域名根目录放置.well-known/assetlinks.json文件,完成应用与域名的关联验证,否则Android 12+系统可能默认让链接跳转浏览器。
  • 测试前清除应用链接关联缓存:可在系统设置的应用详情页,进入「默认应用」→「打开链接」重置关联;或用adb命令直接测试:
    adb shell am start -a android.intent.action.VIEW -d "https://www.example.com/product-name-p-productid"
    
  • 若需保留/account路径的跳转,可在同一个intent-filter中添加多个data标签,或单独编写一个intent-filter处理该路径。

内容的提问来源于stack exchange,提问作者Onur Sumakoglu

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.16 09:52:22