Goal: Help Android developers with a quick and straightforward Android App Links implementation example
If you’re already familiar with the technical details behind the design, configuration, implementation, and verification of Android App Links, and you would like to get started in your own app right away, then this blog post is for you. If you are interested in learning more about those details, we have a codelab that covers them.
Here is what you will need to successfully implement an Android App Link:
Latest version of Android Studio
A deployed domain with public access
(Optional) Google Play developer account setup
Here are the steps to support an Android App Link. These steps create a basic application that displays the Intent information from an App Link.
1.1 In Android Studio create a new project and select “Empty Compose Activity”.
1.2 Make sure the application runs as expected before you start adding code. You should see an empty application with a “Hello Android!” message:
2.1 Include the intent filter in AndroidManifest.xml so the MainActivity will open Android App Links.
2.2 Make sure to update domain example.com and path: /example-path. These should reflect your website implementation structure.
3.1 In order to parse the Android App Link data received you have to add the following logic into the main activity (MainActivity.kt) of your app:
3.2 If you run this logic you will see the following text strings: One displays the Hello Android! message, the second displays the action for the intent that was called, and the third one displays the URL for the intent that was called.
Before uploading the assetlinks.json file, which is part of the Digital Asset Links (DAL) protocol, you need to get the application certificate fingerprint. In this case since we haven’t released the app to the Google Play Store we can use the debug certificate fingerprint. If you want to upload the app to Google Play, you must include your releasing signing key. This page explains how to do it.
4.1 To obtain the debug/release certificate fingerprint, run the following command under the “Run Anything” menu in Android Studio:
Important Note: The debug certificate fingerprint is insecure by nature and should only be used for debugging purposes. The Google Play Store will reject any app downloaded with this certificate.
4.2 From the output of this command, copy the fingerprint under the SHA-256: section:
We have a separate blog post detailing this process. Here we present the short version.
5.1 Under your domain in the following location: <example.com>/.well-known/ include a file called assetlinks.json with the following format:
The resulting link should look something like this: