English | 中文
Hmsanalyticskitdemo provides an example of integrating HUAWEI Analytics Kit with an app. It illustrates how to collect predefined events and custom events to improve user engagement and user preference. Read more about Hianalytics.
You also can use HMS Toolkit to quickly integrate the kit and run the Java demo project, as well as debug the app using a remote device for free. For details, please visit HMS Toolkit.
For more development guidance, please refer to the links below:
In this example, we demonstrate how to use the analytics SDK for Android by using the Gradle build system.
First download Hmsanalyticskitdemo by cloning this repository or downloading an archived snapshot.
In Android Studio, click Open an existing Android Studio project, and select "java" or "kotlin".
You can use the gradlew build command to build the project directly.
You should create an app in AppGallery Connect, and obtain the agconnect-services.json file and add it to the project. More to Development Process.
Use Android Studio to open the decompressed project.
- Create an app in AppGallery Connect and obtain the project configuration file agconnect-services.json. In Android Studio, switch to the Project view and move the agconnect-services.json file to the root directory of the app.
- Change the value of applicationId in the build.gradle file of the app to the name of the app package applied for in the preceding step.
Hardware requirements:
- A computer (desktop or laptop)
- A Huawei phone, which is used to debug the developed app
Software requirements:
- HUAWEI Analytics Kit 6.7.0
- Android SDK applicable to devices using Android 4.3 Jelly Bean (API level 18) and later versions
- Android Studio
- JDK version: 1.8 or later
After running the app 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 Hianalytics 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 Hianalytics as a user attribute.
If you want to evaluate more about HMS Core, HMSCore on Reddit is for you to keep up with latest news about HMS Core, and to exchange insights with other developers.
If you have questions about how to use HMS samples, try the following options:
- Stack Overflow is the best place for any programming questions. Be sure to tag your question with
huawei-mobile-services
. - Huawei Developer Forum HMS Core Module is great for general questions, or seeking recommendations and opinions.
If you run into a bug in our samples, please submit an issue to the Repository. Even better you can submit a Pull Request with a fix.
HmsAnalyticsKitDemo is licensed under the Apache License, version 2.0.