Android M新特性之APP Link

时间:2022-09-20 18:38:20

  The Android M Developer Preview introduces support for App Links, which improves upon existing link handling by allowing app developers to associate an app with a web domain they own.

  Declare a Website Association

  This JSON file indicates the Android app that should be used as the default handler for the URLs under this domain.

The following file listing shows an example of the contents and format of a statements.json file:

[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "<package name>",
    "sha256_cert_fingerprints": ["6C:EC:C5:0E:34:AE....EB:0C:9B"]
  }
}]

Request App Link Verification

  An app can request that the platform automatically verify any app links defined by the host names in the data elements of its intent filters against the statements.json files hosted on the respective web domains. To request app link verification, add an android:autoVerify attribute to each desired intent filter in the manifest, as shown in the following manifest code snippet:

<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="www.android.com" />
        <data android:scheme="https" android:host="www.android.com" />
    </intent-filter>
</activity>

Managing App Link Settings

  Settings > Apps > App Info > Open by default.