Deep Link无法在Android上运行

mip*_*pnw 6 android deep-linking applinks

我正在关注Android开发者文档中的应用内容创建深层链接,以创建Android应用中活动的深层链接.

新的应用程序项目,我已经指定了与该教程完全相同的活动:

<activity
android:name="com.example.android.GizmosActivity"
android:label="@string/title_gizmos" >
<intent-filter android:label="@string/filter_view_http_gizmos">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <!-- Accepts URIs that begin with "http://www.example.com/gizmos” -->
    <data android:scheme="http"
          android:host="www.example.com"
          android:pathPrefix="/gizmos" />
    <!-- note that the leading "/" is required for pathPrefix-->
</intent-filter>
<intent-filter android:label="@string/filter_view_example_gizmos">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <!-- Accepts URIs that begin with "example://gizmos” -->
    <data android:scheme="example"
          android:host="gizmos" />
</intent-filter>
</activity>
Run Code Online (Sandbox Code Playgroud)

当我测试adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.example.android它的工作原理.手机上的操作系统启动了应用程序.

但是,当我通过导航chrome测试example://gizmos应用程序没有启动时,Chrome只会对该URI进行谷歌搜索.为什么不工作?

(我正在使用适用于Nexus 5X API的Android模拟器26).

Ben*_*min 5

如果您手动在地址栏中输入深链接,则可能是由于Chrome无法跟踪深链接。有关更多信息,请参见此答案

测试深度链接的最简单方法是将链接输入Android Messages应用。发送消息后,您可以单击链接。

您还可以在具有深层链接的某个地方托管页面。

  • 我已经尝试过消息应用程序,当我向自己发送一个带有 http 方案的 URI 时,该链接是可点击的并且可以正常工作!出于某种原因,短信中的示例方案没有显示可点击的链接,所以我无法测试 `example://gizmos`,但我没有理由相信它在 `http:// www.example.com/gizmos` 工作正常。谢谢。! (2认同)