深度链接不适用于Android [英] Deep Link does not work on Android

查看:132
本文介绍了深度链接不适用于Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注创建指向应用内容的深层链接

新的应用程序项目中,我已经按照该教程中的说明指定了活动:

New app project, I've specified the activity exactly like in that tutorial:

<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测试时-W -a android.intent .action.VIEW -d example:// gizmos com.example.android 起作用。电话上的操作系统会启动该应用程序。

When I test with adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.example.android it works. The OS on the phone launches the app.

但是当我通过将chrome浏览到 example:// gizmos 进行测试时该应用程序不会启动,C​​hrome只会在Google中搜索该URI。为什么它不起作用?

But when I test by navigating chrome to example://gizmos the app does not launch and chrome just does a google search for that URI. Why isn't it working?

(我使用的是Nexus 5X API 26的Android仿真器)。

(I'm using the Android Emulator for Nexus 5X API 26).

推荐答案

如果您在地址栏中手动键入深铬,则可能是由于Chrome不遵循深层链接。有关更多信息,请参见此 answer

This caused by Chrome not following deep links if you manually type it into the address bar. See this answer for more information.

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

The easiest way to test deep linking is to enter the link into the Android Messages app. After you send the message you can click on the link.

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

You can also host a page somewhere with your deep link.

这篇关于深度链接不适用于Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆