App Links Assistant in Android

Himanshu Choudhary
4 min readJul 26, 2019
Cover Image

What are Android app links ?

Android App Links are HTTP URLs that bring users directly to specific content in your Android app. Android App Links can drive more traffic to your app, help you discover which app content is used most, and make it easier for users to share and find content in an installed app.

Let me explain it with an example if you have installed amazon mobile application on your Android OS phone and you open an amazon product URL on your phone browser then instead of opening that page on the browser — the application is started and that product page is opened.

This is the result of using app links in your Android application. In this post, I am going to tell you about the integration of app links in your Android project.

STEP — 1:

Let’s start it with making a new Android project with an empty activity.

New Project

Once the project is built successfully, add another empty activity but if you have built the project in kotlin language then remember that the new activity should be in java language.

The main reason behind using java language is to link the activity with the app links assistant. If you use kotlin, then the assistant will not be able to recognise onCreate() in your activity and generate an error like

Bug

This is an Android studio bug which can be resolved in future releases.

STEP — 2:

App Links Assistant

Open -> Tools -> App Links Assistant

  • Sub-Steps that you will have to follow:

i. Click on Open URL Mapping Editor

ii. Click on + sign.

iii. Add Host (The base URL of the site on the click of which you want to open the application: In our example, it was https://www.amazon.com)

iv. Select pathPrefix option as Path.

v. Now, enter the prefix URL. For example: If your complete URL of the product is https://www.amazon.in/gp/product/B07J317TRK?pf_rd_p=f2b20090-067d-415f-953d-b8dcecc9109f&pf_rd_r=8859C6EM7HXTE91PM7HH then your prefix URL will be /gp/product

vi. Then, select the java activity that you have created in the activity section.

vii. Enter the whole your URL of the product i.e https://www.amazon.in/gp/product/B07J317TRK?pf_rd_p=f2b20090-067d-415f-953d-b8dcecc9109f&pf_rd_r=8859C6EM7HXTE91PM7HH in Check URL Mapping.

Note: Replace & with &

viii. Select the activity that appears below that field.

ix. Skip the Associate website step as it is to link the website through a Digital Asset Links file. This can also be performed easily. I will not cover this step in this post. If you want to get a reference of it then write it in comments and I will personally do it for you :)

STEP — 3: Final Step

In this step, we will be going to test the code:

Note: If you are using this amazon example then first uninstall the amazon app because then only your will be launched else amazon app will be launched and you will be able to see more into code and can perform experiment with that.

i. Click on Test App Links.

ii. In URL field, paste the URL of the product i.e https://www.amazon.in/gp/product/B07J317TRK?pf_rd_p=f2b20090-067d-415f-953d-b8dcecc9109f&pf_rd_r=8859C6EM7HXTE91PM7HH

iii. Click on Run Test Button and select the connected physical device or the emulator — according to your preference.

Bonus:

If you get an error which will be most probably related to your URL, then check your ‘Check URL Mapping URL’ or ‘Test URL’ or open manifest file and

Check the testURL in your activity and replace all the special symbols like

& — &

< — &gt;

> — &lt; ……etc.

You can find these on the web.

I hope this article would have helped you. In case of any suggestions or queries please do comment.

--

--