Intermediate: Integration of Huawei App Linking in Harmony OS

Introduction

Huawei provides various services for developers to make ease of development and provides best user experience to end users. In this article, we will cover Huawei App Linking with Java in Harmony OS.

In App Linking, you can create both long and short links. It automatically identifies the source of a user and you can set tracing parameters when creating a link of AppLinking which helps you to trace traffic sources. A link created in App Linking can be distributed through multiple channels to users. When a user taps the link, the user will be redirected to the specified in-app content. To identify the source of a user, you can set tracing parameters when creating a link of App Linking to trace traffic sources. By analysing the link performance of each traffic source based on the tracing parameters, you can find the platform that can achieve the best promotion effect for your app and also you can see the data statics of AppLinking in ag-console.

Development Overview

You need to install DevEcho studio IDE and I assume that you have prior knowledge about the Harmony OS and java.

Hardware Requirements

  • A computer (desktop or laptop) running Windows 10.
  • A Huawei phone (with the USB cable), which is used for debugging.

Software Requirements

  • Java JDK installation package.
  • DevEcho studio installed.

Follows the steps.

  1. Create Harmony OS Project.
  • Open DevEcho studio.
  • Click NEW Project, select a Project Templet.
  • Select Empty Ability(Java) template and click Next as per below image.
  • Enter Project Name and Package Name and click on Finish.

2. Once you have created the project, DevEco Studio will automatically sync it with Gradle files. Find the below image after synchronization is successful.

3. Add the below maven URL in build.gradle(Project level) file under the repositories of buildscript, dependencies, for more information refer Add Configuration.

4. Add the below plugin and dependencies in build.gradle(App level)

5. Update Permission and app version in config.json file as per your requirement, otherwise retain the default values.

6. Choose New > Ability, as follows.

7. Development Procedure.

Create MainAbility.java ability and add the below code.

Create ability_main.xml layout and add the below code.

Create background_button_green_color.xml in graphic folder and add the below code.

8. To build apk and run in device, choose Build > Generate Key and CSR Build for Hap(s)\ APP(s) or Build and Run into connected device, follow the steps.

Result

  1. Run Application on connected device, we can see below result.

2. Click on “Create App Link” button, application will show long and short link.

Tips and Tricks

  • Always use the latest version of DevEcho Studio.
  • Use Harmony Device Simulator from HVD section.
  • Do not forgot to add permission in config.json file.
  • Do not forgot to add dependencies in build.gradle.
  • Do not forgot to enable App Linking service.

Conclusion

In this article, we have learnt App Linking Service in Harmony OS. In App Linking, you can create both long and short links which identify in-app link for app and web automatically. When creating a link of AppLinking, it helps you to trace traffic sources.

Thanks for reading the article, please do like and comment your queries or suggestions.

References

Harmony OS: https://www.harmonyos.com/en/develop/?ha_source=hms1

App Linking Overview:

https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agc-applinking-sdkchangenotes-harmonyos-0000001185399065?preview=1

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store