Services
The Wear Kernel implements the services of the Wear Services library.
An application gets each service from KernelServiceProvider.
Kernel Services
Service |
Role |
|---|---|
Registers the activities, the watchfaces, and the complication data sources of the application. Returns the components of all the applications. Sets and returns the navigator. |
|
Returns the battery level (in %), the charging state, the device name, and the Bluetooth address of the device (format |
|
Returns the steps and the calories (in kcal) of the current day, the heart rate (in bpm), the blood oxygen saturation (in %), and the duration of each sleep stage (awake, light, deep, REM, in minutes). |
|
Returns the current time (in milliseconds since the Java Epoch), the time zone ID, and the offset from UTC (in seconds, with daylight saving time). Notifies the registered TimeConfigurationListener instances when the date, the time, or the time zone changes. |
|
Returns the system fonts as MicroVG vector fonts: regular, light, semi bold, bold italic, and monospace. |
|
Returns the absolute resource path of an image of the application, from its path in the application. |
|
Creates, decodes, and deletes external resources (see External Resources). |
External Resources
An external resource is a resource stored outside the application binary, for example on the file system.
External resources are often created at build time, such as the fonts and the images stored on the file system.
An application can also create external resources at runtime, with the ExternalResourceService.
The path of an external resource starts with / and is relative to the directory of the application.
To create an external resource at runtime:
Call
createExternalResource()with the path and the size of the data. To store an image in a format that the display uses directly, callcreateExternalImage()with one of the formatsRGB565,ARGB4444, orA8. The Kernel converts the image when it stores it.Write the data with
Writer.write().Call
Writer.commit(). The resource is then available to the application.Writer.close()withoutcommit()discards the data.
getExternalResourcePath() returns the path to load an external resource.
deleteExternalResource() deletes a resource.
Health Services
Note
The Health Services are a preview. Their API can change in the next releases.
The Health Services give the applications the health data of the user: live values, day reports, sleep reports, and workouts. The health stack of the device sends the sensor data to the Kernel through the Event Queue. The Kernel stores the data and computes the reports. The applications read the data when they need it: the services do not notify them.
The Health Services replace the current HealthService with a new version, and add four services:
Service |
Role |
|---|---|
|
Returns the current heart rate, steps, and calories with |
|
Returns the report of the last night and the reports of the last days. A sleep report gives the start and end time, the total sleep duration, the duration of each stage (awake, light, deep, REM), a sleep score from 0 to 100, the number of awakenings, and the list of sleep phases. |
|
Starts a workout of an activity type, pauses it, resumes it, and adds laps. Stops the workout, and saves or discards it. Returns the live data of the workout: heart rate and heart rate zone (1 to 5), steps, calories, distance (in meters), and pace (in seconds per kilometer). |
|
Returns the reports of the completed workouts: the last one, the last n ones, or the ones of the last days. |
|
Returns and sets the user profile: age, gender, height, weight, heart rate values (maximum, resting, basal), the five heart rate zones, body fat, VO2 max, stride length, and the daily goals for steps, calories, and sleep. |
A workout report (ActivityReport) gives the activity type, the start and end time, the active duration without the pauses, the distance, the elevation change, the pace and heart rate (average and maximum), the time in each heart rate zone, the calories, the start location, the laps, and the samples of each metric during the workout.
The activity type is one of 85 types, such as RUN, TRAIL_RUN, ROAD_BIKE, POOL_SWIM, OPEN_WATER_SWIM, HIKE, STRENGTH, or YOGA.
Laps are available for the activity types that support them.
On the Simulator, the Mock simulates the health data, from its UI or from CSV scenario files.
