Understanding the evolving landscape of health and fitness APIs for wear OS and Android, facilitating smooth transitions and leveraging new functionalities effectively.
This document aims to assist developers in understanding the evolving landscape of health and fitness APIs for Wear OS and Android, facilitating smooth transitions and leveraging new functionalities effectively.
Overview of Wear OS Health APIs and Health Data Integration
Google is currently transitioning from its legacy Google Fit APIs to the more versatile Health Connect and Health Services on Wear OS, as part of a strategic shift in its health and fitness data ecosystem.
This document details the various APIs available, the associated functionalities, and recommended approaches for developers aiming to integrate health data into Wear OS applications effectively.
Google Fit API Deprecation
The Google Fit APIs have been deprecated, with support extended only until June 30, 2025, after which they will be fully phased out. Google recommends transitioning from Google Fit to Health Connect, as it integrates well with modern Android frameworks and Wear OS developments.
Primary Health APIs for Android and Wear OS
1. Health Connect
Health Connect serves as a centralized hub for health and fitness data across multiple platforms. Through Health Connect, supported applications can store, read, and manage health data in a consolidated space.
Key Points:
- Central Hub for Health Data: Health Connect supports integration across multiple fitness and health apps, allowing them to upload or “write” health and fitness data.
- Integration in Android Framework: Starting with Android 14 (API Level 34), Health Connect is embedded within the Android Framework, streamlining data access for developers.
- Supported Platforms: Major platforms compatible with Health Connect include:
-
- Fitbit
- Samsung Health
- Google Fit
Implementation:
- Health Data Management: Health Connect can manage a broad range of health data, such as heart rate, step count, sleep, and more.
-
Cross-Platform Compatibility: Health Connect facilitates compatibility between Android and other systems, such as iOS, through packages like [health Flutter](https://pub.dev/packages/health), which supports both Google Health Connect and Apple Health.
For more details, refer to Google’s guide to getting started with Health Connect.
2. Health Services on Wear OS
Health Services on Wear OS is Google’s API specifically optimized for health and fitness data on Wear OS smartwatches (Wear OS 3 and higher). It enables efficient data collection while minimizing battery consumption through optimized sensor data management.
Key Points:
- Wear OS Optimization: Health Services API is tailored for Wear OS, managing health data collection and reducing battery strain on smartwatches.
- Mandatory for Wear OS 3+: All Wear OS devices running Wear OS 3 and higher require the Wear Health Services API, ensuring consistency for health and fitness app developers.
- Simulated Data: Developers can simulate sensor data for testing through Health Services on Wear OS emulators.
Implementation:
- Data Integration: Sensor data collected via Health Services can be shared through Health Connect for broader health data interoperability.
- Sensor Access: Wear Health Services provides aggregated data but does not directly access raw sensor data. Developers can leverage Android Sensor API for direct access to accelerometer, gyroscope, and GPS data as needed.
- Rate Limiting: Wear Health Services includes rate-limiting mechanisms for sensor data collection, a necessary feature for conserving battery life in wearables.
For sample implementations, refer to Google’s Health Services samples.
Sensor Data Collection in Wear OS
Direct vs. Derived Data Types
Health Services on Wear OS provides both directly available and indirectly derived data categories, as well as limitations in accessing certain raw sensor data. The table below summarizes the data types and limitations:
Data Type Category | Directly Available Data | Indirectly Derivable Data | Not Available Data |
---|---|---|---|
Accelerometer | Step Count (STEPS, STEPS_TOTAL) | Movement Intensity (via SPEED PACE) | 3-Axis Acceleration (X,Y,Z) |
Gyroscope | None | None | 3-Axis Angular Velocity, Rotation |
Location and GPS | Location, Distance, Elevation Changes | Route Mapping | None |
Electrodermal Activity (EDA) | None | None | Skin Conductance, Stress Levels |
Ambient Light | None | None | Light |
Other Health and Activity Data | Heart Rate, Activity data (STEPS, DISTANCE) | None | Sleep, SpO2, Temperature, ECG |
Notes on Sensor Data Access:
- Accelerometer, Gyroscope, and Location Data: To directly access raw data from these sensors, use the Android Sensor API in addition to Health Services.
- Battery Optimization: Continuous, high-frequency data sampling is limited to preserve battery life, especially for power-intensive sensors.
Samsung Health Platform API
The Health Platform API, designed by Samsung, is exclusive to Galaxy devices, including Samsung smartwatches and smartphones. This API provides developers with capabilities to aggregate and access Samsung-specific health and fitness data such as steps, heart rate, and other activity metrics.
Key Points:
- Exclusive Compatibility: Limited to Samsung Galaxy devices, including smartphones and watches.
- Data Aggregation: Aggregates a range of health metrics, but with restrictions to Samsung’s ecosystem, making it less versatile for cross-platform applications.
Summary of Implementation Recommendations
For developers seeking to optimize health and fitness integrations on Android and Wear OS, Google suggests using Health Connect as the primary data hub for cross-platform applications and Health Services on Wear OS for smartwatch-specific features.
Additionally, Android Sensor API may be used to access raw sensor data when required.
Key Transition Dates:
- June 30, 2025: Google Fit API full deprecation; all migrations to Health Connect or Health Services should be complete by this date.
Wear OS App Workflow
Sensor Data Policy
- Can sensor data be collected in the background from Wear OS devices?
Yes, sensor data can be collected in the background on Wear OS, but it’s limited by battery and privacy constraints:
-
For raw sensor data (e.g., accelerometer), the Android Sensor API can be used with foreground services or WorkManager to run in the background, but high-frequency collection drains battery quickly.
-
Bluetooth Low Energy (BLE) can transfer data to a paired smartphone for storage and processing, reducing load on the watch.
Wear OS has restrictions on background activity to save power, so continuous tracking must align with these policies.
- What is the policy / restrictions on background activity in Wear OS to save power?
Wear OS restricts background activity to save power by:
-
App Standby Mode: Apps are restricted from running background tasks when not actively used.
-
Battery Optimization: Limits the use of wake locks and high-frequency sensor access in the background.
-
Foreground Services: Continuous tasks like health tracking require foreground services, which show a persistent notification to the user.
-
WorkManager and AlarmManager: For periodic tasks, these manage background work efficiently without draining the battery.
-
Sensor Rate Limiting: Background sensor data collection is throttled to reduce power consumption.
These policies ensure that apps use fewer resources and extend battery life.
Devices operating on Wear OS:
- Google Pixel Watch
- Google Pixel Watch 2
- Samsung Galaxy Watch4
- Samsung Galaxy Watch4 Classic
- Samsung Galaxy Watch5
- Samsung Galaxy Watch5 Pro
- Samsung Galaxy Watch6
- Samsung Galaxy Watch6 Classic
- Fossil Gen 5
- Fossil Gen 6
- Fossil Gen 6 Wellness Edition
- Mobvoi TicWatch Pro 3
- Mobvoi TicWatch Pro 3 Ultra
- Mobvoi TicWatch E3
- Skagen Falster Gen 6
- Montblanc Summit 2
- Montblanc Summit Lite
- Montblanc Summit 3
- Casio G-Shock GSW-H1000