Android Launches Low-Power Sleep Tracking API

The Sleep API is an Android Activity Recognition API that centralizes sleep detection processing in a battery-efficient manner.

Google Android has long offered an Activity Recognition API, which can detect user’s activities (for example whether a user is biking or walking) to help apps provide contextually aware experiences. Now, in an effort to help users stay informed about their sleep, the company is making its Sleep API publicly available.

The Sleep API is an Android Activity Recognition API that surfaces information about the user’s sleep. Developers can use it to power features like the Bedtime mode in Clock.

The Sleep API makes use of an on-device AI model that uses the device’s light and motion sensors as inputs.

Source: Google

The API reports sleeping information in two ways: a ‘sleep confidence’, which is reported at a regular interval (up to 10 minutes); and a daily sleep segment which is reported after a wakeup is detected.

Like with any Activity Recognition APIs, the app must be granted the Physical Activity Recognition runtime permission from the user to detect sleep.

"Sleep as Android is a swiss army knife for getting a better night’s rest. It tracks sleep duration, regularity, phases, snoring, and more. Sleep Duration is one of the most important parameters to watch for ensuring a good night’s rest. The new Sleep API gives us a fantastic opportunity to track it automatically in the most battery efficient way imaginable." wrote Google

Developers can get the Sleep API as part of the latest version of Google Play Services.