Overview

HUAWEI Health Kit provides an open platform for fitness and health ecosystem data.
Being responsible for managing users' fitness and health data, the ecosystem data platform complies with Huawei's cyber security and user privacy protection specifications, in order to ensure data security, integrity, and accuracy.
Developers can access the ecosystem data platform by integrating HUAWEI Health Kit.
APIs are provided for developers to write users' fitness and health data to the ecosystem data platform. In addition, the ecosystem data platform provides a wide range of data query APIs, through which developers can obtain user's fitness and health data across various data platforms and apps.
The ecosystem data platform manages only the fitness and health data authorized by users.

By integrating the HUAWEI Health SDK into their apps, developers can call the HUAWEI Health Kit APIs to write users' fitness and health data to the ecosystem data platform.
To make this happen, developers need to:

What You Will Create

This codelab provides a basic third-party app development example. You only need to complete the corresponding code fragment to realize the function development of real-time step counting. This function displays the real-time step count curve, step frequency, total number of steps, and calories burnt on the UI.

What You Will Learn

In this codelab, you will learn how to:

Hardware Requirements

Software Requirements

Required Knowledge

Before you get started, complete the following preparations:

For details, please refer to Preparations for integrating HUAWEI HMS Core.

After integrating HUAWEI HMS Core capabilities, you need to apply for the Health Kit service. The preparations are as follows:

【note】 in this codelab, you need to apply for permission to view, store, and view and store the steps in Huawei health kit

For details, please refer to Applying for Health Kit.

Development environment

Android Studio development environment: V3.3.2 or later (recommended).

Configuring the Maven repository address for the SDK

Adding Build Dependencies

The following figure shows the code project and resource structure.

1. Run the initial project (download the original framework code):

2. Add the login code.

3. Request user authorization.

4. Register a listener for real-time data.

5. Read the real-time data.

6. Unregister the listener.

Note: The permission options are not selected by default. You can select permissions based on your requirements.

Well done. You have successfully completed this codelab and learned how to:

  1. Connect to the open capabilities of HUAWEI Health Kit.
  2. Read data from the sensor in real time.

For more information, please click the following link:
Related documents

Download the sample code used in this codelab from the following link:

Download source code

Code copied