English | 中文
HUAWEI Health Kit is the fitness and health capability open service that constructs a fitness and health ecosystem data platform (hereinafter referred to as the ecosystem data platform). As the manager of users' fitness and health data, the ecosystem data platform complies with Huawei's cyber security and user privacy protection specifications to ensure the security, integrity, and accuracy of user data. You can access Huawei's ecosystem data platform by integrating Health Kit. The ecosystem data platform provides APIs for you to write user fitness and health data to the ecosystem data platform, as well as various data query APIs for you to obtain the fitness and health data imported by users across platforms and apps. The ecosystem data platform manages only the fitness and health data authorized by users and provides abundant cross-platform and cross-app query APIs.
This project is the Android sample code of Health Kit. In the sample code, Android APIs of the ecosystem data platform are called to write the user's fitness and health data and read the data written by the user to the platform. The sample code provides only simple calling examples of the Android APIs for your reference.
Before using the sample code, check whether Integrated Development Environment (IDE) has been installed.
- Decompress the sample code package.
- Copy the code package to the IDE directory and import the code package to the IDE.
- Generate a signing certificate fingerprint, add the certificate file to your project, and add the signature configuration to the build.gradle file. For details, refer to Development Guide.
- Click Sync Project with Gradle Files to build the IDE.
Before using the functions in the sample code package, configure the following parameters:
- HUAWEI ID: The Health app needs to verify whether you have the permission to read and write health data.
- HMS SDK Maven address:
- Go to the project build.gradle > allprojects > repositories, configure the Maven address of HMS SDK: maven {url 'https://developer.huawei.com/repo/'}.
- Go to the project build.gradle > buildscript > repositories, configure the Maven address of HMS SDK: maven {url 'https://developer.huawei.com/repo/'}.
- Build dependencies: Add build dependencies implementation 'com.huawei.hms:health:{version}' to the build.gradle file at the app level.
- AppId: Add the app ID generated when creating the app on HUAWEI Developers to the AndroidManifest.xml file of the app.
- Android Studio 3.6.1 or later.
- Java SDK 1.8 or later.
- Mobile Android Version 7.0-13 (API level 24-33) or HarmonyOS. HMS Core (APK) 4.0.2.300 or later has been installed on the phone. To read data from the Health app, HMS Core (APK) 5.0.4.300 or later should be installed. HUAWEI Health app of version 11.0.0.512 or later has been installed.
You can visit the Reddit community to obtain the latest information about HMS Core and communicate with other developers.
If you have any questions about the sample code, try the following:
- Visit Stack Overflow.
Submit your questions, and tag them with
huawei-mobile-services
. Huawei experts will answer your questions. - Visit the HMS Core section in the Huawei Developer Forum and communicate with other developers.
If you encounter any issues when using the sample code, submit your issues or submit a pull request.
The sample code is licensed under Apache License 2.0.