Daily Tech News, Interviews, Reviews and Updates

Health Services now available on Wear OS 3 and higher; Health Services API currently in Beta

Good news for Android developers! Wear OS 3 and higher includes a service called Health Services. It acts as an intermediary to the various sensors and related algorithms on the device to provide apps with high-quality data related to activity, exercise, and health.

Health Services API is in beta and is ready for production use.

Health Services on Wear OS

Health Services automatically configures all fitness and health-related sensors appropriately for the use case, collects sensor data, and computes metrics like heart rate, distance, calories, elevation, floors, speed, pace, and more. Apps can register for this data directly from Health Services.

Some of the benefits of using Health Services

  • Takes advantage of powerful algorithms running natively on the platform.
  • Conserves battery by using sensor configurations from Health Services that are optimized for power efficiency.
  • Future-proofs an app for Wear 3+ devices. The Health Services API is consistent across Wear 3+ devices, making it easier to keep your app up to date.
  • Ensures data consistency across all applications on the same device by using standardized platform computations.
  • Enables activity-aware experiences, including the ability to detect an ongoing exercise started from another app.

Developers should keep the following concepts in mind when developing with Health Services

1. Data types- Health Services offers a variety of data collected and continuously updated from all the available sources on the device. The data falls into two broad categories: data sampled at a single point in time, such as HEART_RATE_BPM, and data taken over a time interval, such as DISTANCE.

2. Events- Apps receive events when the user reaches a certain goal state or event. For example, a user can register a distance goal within an exercise app, and then the app notifies the user when they have run a certain distance. Alternatively, use a passive goal for situations like the user hitting a certain step count or falling asleep.

3. Exercise Types- Health Services treats exercise as a first-class feature and supports a multitude of exercise types, such as running or skiing. While an exercise is in progress, Health Services can collect metrics on selected data types and report back to the app that manages the exercise.

Developers can create apps using Health Services as described in the following sections

Passive experiences

Using PassiveMonitoringClient, your app implements a PassiveListenerService that receives updates about a data type or an event. This is suited for long-lived experiences where data updates are relatively infrequent.

Active experiences

Using MeasureClient, your app registers listeners to receive rapid data updates. This is suited for short-lived experiences, such as while the user looks at your app UI. Try to minimize the time your app spends with a registered listener because it increases the sensor sampling rate and thus increases power consumption. This API is not intended for background capture or workout tracking.

Using ExerciseClient, your app can manage a user’s workout, set exercise goals, and listen for updates about the current exercise state. Your app can also receive rapid data updates through this API, as long as the exercise belongs to your app. ExerciseClient can be used for apps such as a running app that lets users record their run, displays live metrics on their device, and records data for further analysis.

Test with Synthetic data

To test that your app is receiving data updates from Health Services, manually set your device to emit data as if a user were engaged in an exercise.

Get real time updates directly on you device, subscribe now.



You might also like