Deep Link does not work on Android

走远了吗. 提交于 2020-05-12 20:32:30

问题


I'm following Create Deep Links to App Content in Android developer documentation to create a Deep Link to an Activity in an Android app.

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>

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.

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?

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


回答1:


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

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.



来源:https://stackoverflow.com/questions/49713357/deep-link-does-not-work-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!