Ganesh Pandey
Ganesh Pandey

Reputation: 5276

How to implement app links on android marshmallow?

App links are being changed in Android 6.0, so that Android has a greater awareness of which apps can open content directly, instead of stopping users every time with the dialog box.

How do i implement it?

Upvotes: 1

Views: 1132

Answers (1)

Ganesh Pandey
Ganesh Pandey

Reputation: 5276

Well yes App Links is new and cool features on Android Marshmallow 6.0. which lets a aster way of opening website links for domains that you own.

There are two Conditions need to meet for applinks:

  1. Add <intent-filter> for urls
  2. Verify ownership of domain

Make sure you have at least 1 activity with intent filter in it.

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

Intent filters for app links must declare an android:scheme value of http, https, or both. The filter must not declare any other schemes. The filter must also include the android.intent.action.VIEW and android.intent.category.BROWSABLE category names.

Don't forget to add android:autoVerify="true" attribute on <intent-filter> This will tell the system to start the domain verification while the app install on the device.

Now to associate your site with your app you need to add Digital Asset Link JSON file on your site. Exactly the same path under your website root directory

https://www.domain.com/.well-known/assetlinks.json

The following example assetlinks.json file grants link-opening rights to a com.example Android app:

This is what JSON file look like:

[{
  "relation": ["delegate_permission/common.handle_all_urls"],
  "target": {
    "namespace": "android_app",
    "package_name": "com.example",
    "sha256_cert_fingerprints":
    ["14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5"]
  }
}]

Just have to replace the value "package_name": and "sha256_cert_fingerprints": Leave others as it is.

Make sure the file you create is accessible over HTTPS protocal

Now you can test the app, for tests you can follow the instruction from android developer documentation blog

Upvotes: 7

Related Questions