1. 简介

官方介绍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.

Create Deep Links to App Content

2. 与DeepLink的区别


A [deep link] is an intent filter that allows users to directly enter a specific activity in your Android app. 
Clicking one of these links might open a disambiguation dialog, which allows the user to select one of 
multiple apps (including yours) that can hande the given URL. For example, figure 1 shows the 
disambiguation dialog after the user clicks a map link, asking whether to open the link in Maps or Chrome.


The disambiguation dialog


Item Deep links App links
Intent URL scheme http, https, or a custom scheme Requires http or https
Intent action Any action Requires android.intent.action.VIEW
Intent category Any category Requires android.intent.category.BROWSABLE and android.intent.category.DEFAULT
Link verification None Requires a Digital Asset Links file served on you website with HTTPS
User experience May show a disambiguation dialog for the user to select which app to open the link No dialog; your app opens to handle your website links
Compatibility All Android versions Android 6.0 and higher


官方给的步骤如下Handling Android App Links

3.1 在manifest中开启autoVerify

<activity ...>

    <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:scheme="http" android:host="" />
        <data android:scheme="https" />


这里注意下,开启autoVerify的activity中的<intent-filter..>的action必须为android.intent.action.VIEW,category必须包含android.intent.category.BROWSABLE,data的scheme必须包含http/https,否则不生效,而且AppLinks必须在Android 6.0 以上的手机才可生效。验证包含以下几方面:

  1. 系统会检查包含以下几方面的所有intent-filter
  • Action: android.intent.action.VIEW
  • Categories: android.intent.category.BROWSABLE and android.intent.category.DEFAULT
  • Data scheme: http or https
  1. 原话是:For each unique host name found in the above intent filters, Android queries the corresponding websites for the Digital Asset Links file at https://hostname/.well-known/assetlinks.json.。翻译过来就是系统会读取网站的/.well-known/assetlinks.json文件,然后验证包名和签名是否包含在assetlinks.json文件中。


3.2 支持多hosts的绑定。

  <data android:scheme="https" android:host="" />
  <data android:scheme="app" android:host="" />

上面在同一个<intent-filter ..>里面写的两个<data ..>,他们除了组合https://www.example.comapp://也是满足上面的<intent-filter ..>的。而分开写的时候,不存在上面的问题。

3.3 在网站上创建assetlinks.json文件


  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "com.example",


  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "",
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "",



Be sure of the following:

*   The `assetlinks.json` file is served with content-type `application/json`.
*   The `assetlinks.json` file must be accessible over an HTTPS connection, regardless of whether your app's intent filters declare HTTPS as the data scheme.
*   The `assetlinks.json` file must be accessible without any redirects (no 301 or 302 redirects) and be accessible by bots (your `robots.txt` must allow crawling `/.well-known/assetlinks.json`).
*   If your app links support multiple host domains, then you must publish the `assetlinks.json` file on each domain. See [Supporting app linking for multiple hosts](
*   Do not publish your app with dev/test URLs in the manifest file that may not be accessible to the public (such as any that are accessible accessible only with a VPN). A work-around in such cases is to [configure build variants]( to generate a different manifest file for dev builds


3.4 测试AppLinks

  1. 测试json文件是否正确,请看 Statement List Generator and Tester
  1. 测试intent是否正确
adb shell am start -a android.intent.action.VIEW \
    -c android.intent.category.BROWSABLE \
    -d ""


adb shell dumpsys package domain-preferred-apps


adb shell dumpsys package d


Status: always : 200000002


* Package - Identifies an app by its package name, as declared in its manifest.
* Domains - Shows the full list of hosts whose web links this app handles, using blank spaces as delimiters.
* Status - Shows the current link-handling setting for this app. An app that has passed verification, and 
whose manifest contains android:autoVerify="true", shows a status of always. The hexadecimal number after 
this status is related to the Android system's record of the user’s app linkage preferences. This value does 
not indicate whether verification succeeded.

4. 总结

  1. 优点:
  • 不会弹选择框
  • 可以直接通过url跳到对应的activity
  1. 缺点:
  • 网站需要支持https
  • 有个校验过程,步骤麻烦些。