What:
谷歌的App Link让用户在点击一个普通web链接的时候可以打开指定app的指定页面,前提是这个app已经安装并且经过了验证,否则会显示一个打开选项的弹出框。自此,在安卓中打开一个链接的用户体验大大提高,用户可以在链接与app之间快速切换。
官方介绍Android App Links内容是:
Android App Links are a special type of deep link that allow your website URLs to immediately open the
corresponding content in your Android app (without requiring the user to select the app).To add Android App Links to your app, define intent filters that open
your app content using HTTP URLs (as described in [Create Deep Links
to App Content]), and verify that you own both your app and the
website URLs (as described in this guide). If the system successfully
verifies that you own the URLs, the system automatically routes those
URL intents to your app.
Why:
哪些场景可以用到呢?
比如:ARouter 路由 url 跳转的方式;Web端、H5调用原生页面等。
How:
进入正题:
官方给的步骤如下Handling Android App Links
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.infrastructure">
<application>
<activity android:name=".router.SchemeFilterActivity">
<!-- Scheme -->
<intent-filter>
<data
android:host="m.knowledge.com"
android:scheme="arouter"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
</intent-filter>
<!-- App Links -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:host="m.knowledge.com"
android:scheme="http"/>
<data
android:host="m.knowledge.com"
android:scheme="https"/>
</intent-filter>
</activity>
<activity android:name=".router.ARouterTestActivity" />
</application>
</manifest>