Intermediate: Integration of HMS App linking in Android application

HMS App Linking allows you to create cross-platform links that can work as defined regardless of whether your app has been installed by a user. When a user taps the link on an Android or iOS device, the user will be redirected to the specified in-app content. If a user taps the link in a browser, the user will be redirected to the same content of the web version.

Manoj Kumar
4 min readMay 28, 2021

Overview

In this article, I will create an Android Demo app which highlights integration of HMS App Linking in Android App.

I will create an AppGallery project and will deploy AppGallery into the application.

HMS App Linking Introduction

HMS App Linking allows you to create cross-platform links that can work as defined regardless of whether your app has been installed by a user. When a user taps the link on an Android or iOS device, the user will be redirected to the specified in-app content. If a user taps the link in a browser, the user will be redirected to the same content of the web version.

To identify the source of a user, you can set tracing parameters for various channels when creating a link of App Linking to trace traffic sources. By analyzing the link performance of each traffic source based on the tracing parameters, you can find the platform that can achieve better promotion effect for your app:

1. Deferred deep link: Directs a user who has not installed your app to AppGallery to download your app first and then goes to the linked in-app content directly, without requiring the user to tap the link again.

2. Link display in card form: Uses a social meta tag to display a link of App Linking as a card, which will attract more users from social media.

3. Statistics: Records the data of all link-related events, such as numbers of link taps, first app launches, and non-first app launches, for you to conduct analysis.

Prerequisite

1. Huawei Phone

2. Android Studio

3. AppGallery Account

App Gallery Integration process

1. Sign In and Create or Choose a project on AppGallery Connect portal.

2. Navigate to Project settings and download the configuration file.

3. Navigate to General Information, and then provide Data Storage location.

4. Navigate to Manage APIs and enable APIs which is required by application.

5. Navigate to AppLinking and Enable.

6. Add New link.

7. Navigate to App Linking and select Set domain name.

8. Copy Domain Name and add in your project.

App Development

1. Create a New Project.

2. Configure Project Gradle.

3. Configure App Gradle.

4. Configure AndroidManifest.

5. Create Activity class with XML UI.

MainActivity.java:

This activity performs all the operation of AppLinking with short and long url with Share card.

main_activity.xml:

App Build Result

Tips and Tricks

1. The App Linking function is provided by Android. However, if GMS is installed on a mobile phone, GMS will override the verification process of Android. In the verification mechanism of GMS, the https://digitalassetlinks.googleapis.com/v1/statements:list API is called. However, the API cannot be accessed normally from the Chinese mainland.

2. If a user has not installed your app or AppGallery, they will first be redirected to your app’s details page on the web version of AppGallery by default, and then receive a prompt to download AppGallery. You are advised to set the link behaviour to open a local app store. This will allow App Linking to use the MARKET protocol, so that the user can choose among all of the app markets installed on the device. You can also set a custom URL, allowing the user to download your APK file directly from that URL.

Conclusion

In this article, we have learned how to integrate AppLinking in application. In this application, I have explained that how to deep link our application with URL.

Thanks for reading this article. Be sure to like and comments to this article, if you found it helpful. It means a lot to me.

References

HMS AppLinking Doc

https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-applinking-introduction-0000001054143215

--

--

Manoj Kumar
Manoj Kumar

No responses yet