Low-power sleep tracking on Android

Posted by Nick Grayson, Product Manager

Illustration of phone with moon and android logo on the screen

Android works best when it helps developers create apps that people love. Because of this, we strive to provide useful APIs like Activity Recognition that allow the user to identify the user’s activities (e.g. whether a user is cycling or walking) to help apps deliver contextual experiences.

So much of what we do depends on a good night’s sleep. Our phones have become great tools for making more informed decisions about our sleep. And when people are informed about sleep habits, they can make better decisions about sleep throughout the day, which affects things like focus and mental health.

To help our users stay up to date on their sleep, we are making our sleep API publicly available.

What is the Sleep API?

The Sleep API is an Android activity detection API that displays information about the user’s sleep. It can be used to enable features like bedtime mode in Clock.

This sleep information is reported in two ways:

  1. A “sleep confidence” reported at regular intervals (up to 10 minutes).
  2. A daily sleep segment reported when you wake up is recognized

The API uses an artificial intelligence device model that uses the device’s light and motion sensors as inputs.

As with all of our activity detection APIs, the app must be given runtime permission by the user to detect physical activity in order to detect sleep.

Why is this important for developers?

Developers spend valuable engineering time combining sensor signals to determine when the user started or stopped activities such as sleep. These detection algorithms are inconsistent between apps. When multiple apps independently and continuously check for changes in user activity, battery life suffers.

The Sleep API is a simple API that centralizes sleep detection processing in a battery efficient manner. For this launch, we are proud to partner with Urbandroid, the developer of the popular Sleep As Android alarm app

Android logo sleep

Sleep as Android is a Swiss Army Knife for a better night’s sleep. It records sleep duration, regularity, phases, snoring and more. Sleep duration is one of the most important parameters to ensure a good night’s sleep. The new Sleep API gives us a fantastic way to automatically track them in the most battery efficient way imaginable.

– Sleep as an Android team

When can I start using this API?

The Sleep API is now available to developers as part of the latest version of Google Play Services.

This API is a step in our efforts to help our users get a better night’s sleep. We look forward to working more on this API and in this area in the future.

If you would like to explore or use this API, see our API documentation.

Recent Articles

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here

Stay on op - Ge the daily news in your inbox