List of key APIs (e.g., sensor data, health monitoring, location services, etc.) in Wear OS (Google)
Wear OS provides a variety of APIs that allow developers to access key features such as sensor data, health monitoring, location services, and other essential functionalities tailored for wearable devices. Below is a detailed list of Wear OS APIs with their descriptions.
1. Sensors API
Wear OS devices come with several sensors that can track health, fitness, and environmental data. The Sensors API allows you to read data from sensors like heart rate, accelerometers, and gyroscopes.
Key Sensor Types:
-
Heart Rate Sensor: Measures the user’s heart rate.
kotlinval sensorManager = getSystemService(SENSOR_SERVICE) as SensorManagerval heartRateSensor = sensorManager.getDefaultSensor(Sensor.TYPE_HEART_RATE) sensorManager.registerListener(object : SensorEventListener {override fun onSensorChanged(event: SensorEvent?) {if (event?.sensor?.type == Sensor.TYPE_HEART_RATE) {val heartRate = event.values[0]// Process heart rate data}}override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) {}}, heartRateSensor, SensorManager.SENSOR_DELAY_UI)
-
Step Counter: Tracks the number of steps the user has taken.
kotlinval stepSensor = sensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER)
sensorManager.registerListener(stepListener, stepSensor, SensorManager.SENSOR_DELAY_UI)
-
Accelerometer: Measures the acceleration force applied to the device, often used for detecting motion or changes in orientation.
Key Classes:
SensorManager: Used to manage sensors.SensorEventListener: Interface for receiving sensor data.Sensor: Represents a physical sensor on the device.
2. Health and Fitness API
Wear OS provides several APIs that specifically focus on health-related data such as heart rate, steps, sleep, and calories. These are available via Google Fit and Wearable Data Layer API.
Key Health and Fitness APIs:
- Google Fit API: Provides access to health and fitness data such as activity, heart rate, and sleep tracking.
- Recording API: Allows you to record fitness data (e.g., steps, calories).
- History API: Lets you retrieve past health data.
Example of recording heart rate data:
Fitness.getRecordingClient(context, account)
.subscribe(DataType.TYPE_HEART_RATE_BPM)
-
Wearable Data Layer API: Allows apps on Wear OS to communicate and sync data with companion devices (like smartphones).
- PutDataRequest: Allows you to send data from the wearable device to the phone.
- GetDataItem: Allows you to retrieve data sent from the wearable device.
3. Location API
Wear OS devices come with GPS, which allows apps to track the device’s location. The Location API enables you to obtain real-time location updates.
Key Location Services:
-
Fused Location Provider: A high-level API for obtaining the user’s current location, which combines data from GPS, Wi-Fi, and other sensors.
kotlinval fusedLocationClient = LocationServices.getFusedLocationProviderClient(context)
fusedLocationClient.lastLocation.addOnSuccessListener { location: Location? ->
// Process location
}
-
Geofencing API: Allows you to create virtual boundaries for the device. When the device enters or exits the geofenced area, you can trigger actions.
kotlinval geofencingClient = LocationServices.getGeofencingClient(context)
val geofence = Geofence.Builder()
.setRequestId("geo-fence-id")
.setCircularRegion(latitude, longitude, radius)
.setExpirationDuration(Geofence.NEVER_EXPIRE)
.setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER or Geofence.GEOFENCE_TRANSITION_EXIT)
.build()
4. Bluetooth API
Wear OS devices can communicate with other Bluetooth-enabled devices such as smartphones, headsets, or other wearables. The Bluetooth API allows you to manage Bluetooth connections.
Key Bluetooth Services:
- BluetoothAdapter: The main entry point for managing Bluetooth on the device.
- BluetoothGatt: Used for communicating with Bluetooth Low Energy (BLE) devices.
Example of discovering nearby Bluetooth devices:
val bluetoothAdapter = BluetoothAdapter.getDefaultAdapter()
bluetoothAdapter.startDiscovery()
5. Ambient Mode API
The Ambient Mode API is a key feature for Wear OS apps to provide a low-power mode for always-on screens. It allows developers to define a secondary UI (an “ambient” mode) that is shown when the watch is in a low-power state.
Key Features:
- Ambient Mode: Displays a simplified, battery-efficient version of your app.
- OnAmbientModeChangedListener: Listens to changes between interactive and ambient modes.
Example:
override fun onEnterAmbient(ambientDetails: Bundle?) {
// Enter ambient mode
}
override fun onUpdateAmbient() {
// Update ambient mode UI
}
override fun onExitAmbient() {
// Exit ambient mode
}
6. Complications API
The Complications API allows you to display additional information on the watch face (such as weather, time, health stats) in the form of small widgets.
Key Classes:
- ComplicationData: Contains the data to be shown in the complication.
- ComplicationManager: Manages complications and updates their data.
Example:
val complicationData = ComplicationData.Builder(ComplicationType.SHORT_TEXT)
.setShortText(ComplicationText.plainText("Heart Rate"))
.build()
complicationManager.updateComplicationData(complicationData)
7. Connectivity APIs
Wear OS supports multiple ways for devices to connect, both with each other and with other devices, through Wi-Fi, Bluetooth, or cellular data.
Key APIs:
- DataClient API: Used for transferring data between wearable devices and mobile devices.
- MessageClient API: Allows apps to send and receive messages.
Example of sending a message to the paired device:
val messageClient = Wearable.getMessageClient(context)
messageClient.sendMessage(nodeId, "/path/to/message", "Hello Wear OS".toByteArray())
8. Media APIs
Wear OS provides APIs for managing and controlling media playback (such as music or videos) on the device.
Key Media APIs:
- MediaPlayer: Allows you to play media files.
- MediaSession: Manages media playback.
9. Watch Face APIs
Developers can create custom watch faces for Wear OS devices. The Watch Face API enables you to design a personalized, interactive watch face that displays time and additional information.
Key Features:
- WatchFaceService: Base class for creating a custom watch face.
- CanvasWatchFaceService: A subclass of
WatchFaceServicefor drawing your watch face using aCanvas.
Example:
class MyWatchFaceService : CanvasWatchFaceService() {
override fun onCreateEngine(): Engine {
return MyEngine()
}
inner class MyEngine : CanvasWatchFaceService.Engine() {
override fun onDraw(canvas: Canvas, bounds: Rect) {
// Custom drawing logic
}
}
}
Summary of Key Wear OS APIs:
| API | Function |
|---|---|
| Sensors API | Access to device sensors like heart rate, accelerometer, step counter. |
| Google Fit API | Access and record health and fitness data. |
| Location API | Obtain device location and set up geofencing. |
| Bluetooth API | Manage Bluetooth connections to other devices. |
| Ambient Mode API | Manage low-power display mode. |
| Complications API | Display small widgets on the watch face for extra data (e.g., heart rate). |
| Connectivity APIs | Send data and messages between Wear OS and mobile devices. |
| Media APIs | Control and manage media playback on the wearable device. |
| Watch Face API | Create and manage custom watch faces. |
These APIs provide the building blocks for developing robust and feature-rich Wear OS applications that can interact with sensors, health data, location services, and much more, enabling seamless experiences for wearable device users.
I’m a developer of the Wear OS app. I’m trying to make a health monitoring app, so can you explain some of the main APIs of Wear OS?
I especially want to know about sensor data collection and health data access! 🔍
Hello! Let me summarize the core APIs of Wear OS.
I think the Health Services API is the most important thing. It gives you easy access to heart rate, exercise tracking, sleep data, etc. Especially with the Passive Monitoring Client, you can continuously monitor your health data in the background.
When it comes to sensors, pay attention to the Sensors API:
Sensor Manager provides access to low data such as accelerometers, gyroscopes, and heart rate sensors
Specify the desired sensor with a constant such as TYPE_HEART_RATE or TYPE_STEP_COUNTER
Batch Sensor Manager enables efficient battery data collection
For location service, the FusedLocationProvider API is standard. It provides indoor/outdoor location tracking, geo-fencing, activity recognition, and more.
How do I set permissions when using the Health Services API?
And is there a best practice that collects real-time data while reducing battery consumption? 🤔
Health Services requires pretty tricky permission settings!
By default, AndroidManifest.xml requires these privileges:
<uses-permission android=”android.permission.BODY_SENSORS” />
<uses-permission android=”android.permission.ACTIVITY_RECOGNITION” />
<uses-permission android=”android.permission.health.READ_HEART_RATE” />
Tips for battery optimization when collecting real-time data:
- Scheduling Periodic Data Collection Using WorkManager
- Collect sensor data with batch processing (utilizing sampling periodUs by SensorManager.registerListener)
- Lower the sampling rate when the screen is off
- Unleash unnecessary sensors immediately
It’s like this in the actual code:
workManager.enqueueUniquePeriodicWork(
“healthTracking”,
ExistingPeriodicWorkPolicy.KEEP,
PeriodicWorkRequestBuilder<HealthWorker>(15, TimeUnit.MINUTES)
.setConstraints(constraints)
.build()
)
This will collect data every 15 minutes while saving the battery! 😊
![WEARABLE_INSIGHT [FORUM]](https://wearableinsight.net/wp-content/uploads/2025/04/로고-3WEARABLE-INSIGHT1344x256.png)

