Overview of Health Platform Sample
mainHealthDataClient API. It serves as a reference for interacting with the Samsung Health Platform.repository·main·Indexed 43 days ago
https://github.com/android/health-samplesA collection of Android Studio reference implementations for health-related APIs on Android and Wear OS. Includes samples for Health Connect, the Samsung Health Platform using the HealthDataClient API, and Wear OS Health Services featuring ExerciseClient, MeasureClient, and PassiveMonitoringClient.
HealthDataClient API. It serves as a reference for interacting with the Samsung Health Platform.This repository provides a collection of individual Android Studio projects designed to help developers implement Health Services on Wear OS.
Important Note on API Stability: The Health Services API is currently in alpha release. This means APIs are subject to being added, removed, or changed. It is not recommended for production use at this time.
The Exercise Sample demonstrates how to use the ExerciseClient API to manage an exercise session.
Key features demonstrated include:
Note on testing: If you are testing on a device without active user movement, you may need to use a synthetic data provider to prevent Health Services from immediately pausing the exercise due to inactivity.
The sample demonstrates how to expose heart rate data to watch faces using a complication via HeartRateComplicationService.
PlatformHealthSources.heartRateBpm() wrapped in a DynamicComplicationText. On API 33+, the platform re-evaluates this expression roughly once per second in interactive mode, allowing for live updates without waking the complication service.PassiveDataService.PassiveDataService calls ComplicationDataSourceUpdateRequester.requestUpdateAll() when new data arrives to ensure the fallback text and older device paths stay current.BODY_SENSORS (or READ_HEART_RATE on API 36+).The PassiveMonitoringClient is used to receive updates in the background without requiring the app to be in the foreground. Two specific sample implementations demonstrate this:
The ExerciseClient API is used to manage a full exercise session, including starting, stopping, and monitoring an active exercise experience.
See the ExerciseSample for a complete implementation of exercise management.
The MeasureClient is used when your application needs to receive rapid, high-frequency data updates while the app is running in the foreground.
See the MeasureData sample for a concrete implementation of this pattern.
The health-platform-v1/ directory contains samples for reading and writing health, fitness, and wellness data using the Health Platform.
Warning: Health Connect is the preferred choice for new integrations over the Health Platform.
The sample includes functionality to generate and insert dummy fitness/health data into the Health Platform.
When triggered, the app attempts to generate data and insert it. If necessary, the app will present permission grants to the user. Once inserted, this session data is visible to any other clients (such as Samsung Health) that have been granted the corresponding READ permission in the Health Platform.
To run this sample, you must have a Wear OS device with Health Services installed.
Upon startup, the app detects if steps and floors data are available. If available, you can use the UI switch to enable or disable goal subscriptions. The sample implements two specific goals:
Use the samples in the health-connect/ directory to learn how to read, write, and share health, fitness, and wellness data using the Health Connect API.
Note: For new integrations, developers should use Health Connect instead of the Health Platform.