Android 12及以上版本DeepLink跳转异常问题排查
Android 12及以上版本DeepLink跳转失效问题
我用Java开发了一款基于Android的example.com WebView应用。在Android 12之前的版本中,用户点击任意相关链接(例如https://example.com/xyz/)时,只要应用已安装,链接就会在APP内打开;但在Android 12及以上版本中,链接始终跳转到浏览器。
我已完成Android 12及以上版本DeepLink配置的全部必要步骤:
- 更新Android Manifest文件
- 使用APK生成的SHA256指纹创建
assetlinks.json文件 - 将
assetlinks.json部署至服务器的https://example.com/.well-known/assetlinks.json路径 - 校验
assetlinks.json的准确性 - 在Android端验证配置修改
测试结果显示「Success Host example.com grants app...」,但跳转功能仍未生效。以下是我的相关代码:
AndroidManifest.xml
<activity android:name=".MainActivity" android:exported="true" > <!-- - - -Deeplink--> <intent-filter android:autoVerify="true" tools:targetApi="m"> <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" android:host="*example.com" android:pathPattern=".*" /> <data android:scheme="https" android:host="*example.com" android:pathPattern=".*" /> </intent-filter> <!-- Deeplink- - - --> <meta-data android:name="android.app.lib_name" android:value="" /> </activity>
MainActivity.java
//... @Override protected void onCreate(Bundle savedInstanceState) { //... String URL = "https://example.com"; Intent intent = getIntent(); Uri data = intent.getData(); if (Intent.ACTION_VIEW.equals(intent.getAction()) && data != null) { String path = data.getPath(); URL += path; } webview.loadUrl(URL); //... }
内容的提问来源于stack exchange,提问作者perps4214213
相关产品推荐
相关产品推荐

