We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
Notice on Closing the Huawei Analytics Service Access Portal

Dear developer!

Due to business adjustments, we will close the entrance for Huawei Analytics services on June 30, 2024 and no longer support new user registration. Developers of projects that have already activated Huawei Analytics services are not affected and can still continue to use Huawei Analytics services. If there are any changes, we will notify them separately. Thank you for your support!

SamplesAnalytics KitQuick App Sample Code

Quick App Sample Code

The sample code provides a demo project that demonstrates how to call open APIs of Analytics Kit. Guided by the demo, you will learn how to:

  • Efficiently integrate Analytics Kit.
  • Correctly use APIs of Analytics Kit.
Expand

Sample Code

Find It on Gitee

Find It on GitHub

Quick app sample code

Click here

Click here

NOTE

You can use the sample code only after completing the following operations:

  1. Sign in to AppGallery Connect, click My projects, and click the app for which you want to integrate the Analytics SDK. Go to Project settings, download the agconnect-services.json file, and set the value of the custom variable agConnectConfig to the content of the agconnect-services.json file. Copy the agConnectConfig code snippet to the app.ux file of your project, and initialize the Analytics SDK by referring to the README file in the demo project.
  2. Start the demo project.

    1. Connect your phone to your computer and ensure that your phone is in debug mode.
    2. Click the real-time compilation button or press shortcut keys Ctrl+Shift+R.
    3. Upon successful startup, the quiz demo is displayed in the real-time preview window on the right of the phone and IDE.
Search in Samples
Enter a keyword.