Android Deep Link
使用场景
用户在网页点击了一个链接以后,直接引导用户在本地应用中查看对应的内容。
原理
当我们点击或者自动化的网络请求会生成一个web URI intent,Android系统按照一定顺序去处理这个请求。
处理顺序为:1.打开所有可以处理本URL应用中用户默认选择的;2.打开唯一能处理这个URL的应用;3.将所有可以处理这个URL的应用展示在Dialog中让用户选择
基本步骤
- 在manifest文件中定义IntentFilter
- 建立对应处理的Activity
- (对于Android App Link而言)将本地内容与URL地址通过服务器上的Digital Asset Links文件关联起来
辅助工具
Android Studio的App Link Assistant使用说明:官方使用指南
分类
Deep Link,Android App Link
Deep Link
配置
- 在Manifest中增加intent filter
<action>
: ACTION_VIEW<category>
: 包含BROWSABLE,DEFAULT.BROWSABLE(必须包含,才可以处理来至l浏览器的Intent Filter)<data>
: 指定可以响应的URI信息,至少包含scheme标签,可以使用path,pathPattern或者pathPrefix去处理相似的URI
// 可以响应example://gizmos 和 http://www.example.com/gizmos的Activity
<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">
<