English | 中文
AnalyticsKitDemo provides an example of integrating HUAWEI Analytics Kit with an Hap
. It illustrates how to collect predefined events and custom events to improve user engagement and user preference.
Read more about Analytics Kit.
For more development guidance, please refer to the links below:
In this example, we demonstrate how to use the analytics SDK for HarmonyOS by using the Gradle build system.
First download AnalyticsKitDemo by cloning this repository or downloading an archived snapshot.
In HUAWEI DevEco Studio, click Open Project, and select AnalyticsKitDemo.
You can use the gradlew build command to build the project directly.
You should create an Hap
in AppGallery Connect, and obtain the agconnect-services.json
file and add it to the project. You should also generate a signing certificate fingerprint and add the certificate file to the project, and add configuration to the build.gradle file. More to Development Process.
Use HUAWEI DevEco Studio to open the decompressed project.
- Create an Hap in AppGallery Connect and obtain the project configuration file agconnect-services.json. In HUAWEI DevEco Studio, switch to the Project view and move the agconnect-services.json file to the root directory of the
entry
. - Change the value of
bundleName
in the config.json file of theentry
to the name of theHap
package applied for in the preceding step.
Hardware requirements:
- A computer (desktop or laptop)
- A Huawei phone, which is used to debug the developed
Hap
Software requirements:
- HUAWEI Analytics Kit 6.2.0
- HarmonyOS SDK applicable to devices using HarmonyOS 2.0.0 (API level 4) and later versions
- HUAWEI DevEco Studio
- JDK version: 1.8 or later
After running the Hap you should see a screen like this:
Click True or False to answer the question; Click Next to show the next question; Click Post Score, log the score user got. All the information will be uploaded to the Analytics Kit Console, and you can see these information in real time using Debug View.
Click button Settings:
When you click Settings, you will be asked for your favorite sport. Your choice will be logged by Analytics Kit as a user attribute.
AnalyticsKitDemo is licensed under the Apache License, version 2.0.