我正在关注Android开发人员文档中的Create Deep Links to App Content,以在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>
当我用 adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.example.android
进行测试时,它可以工作 . 手机上的操作系统启动应用程序 .
但是,当我通过导航chrome到 example://gizmos
进行测试时,应用程序无法启动,Chrome只会对该URI进行谷歌搜索 . 为什么不工作?
(我正在使用适用于Nexus 5X API 26的Android模拟器) .
1 回答
如果您手动将其键入地址栏,则Chrome不会导致深层链接 . 有关更多信息,请参阅answer .
测试深层链接的最简单方法是在Android消息应用中输入链接 . 发送消息后,您可以单击链接 .
您还可以使用深层链接在某处托管页面 .