Sleep tracking apps on Android have been less than stellar up to this point. They've had all sorts of issues, and they absolutely crush a smartphone's battery life in a truly unacceptable way.
But that's about to change, as Google has announced a new Sleep API on the Android Developers Blog. With the publically-available API, app developers will be able to create more functional sleep tracking applications with fewer issues and minimal crashes.
What Does Google's Public Sleep API Do?
The new API sounds like a dream for app developers who want to help users sleep more soundly and know how their sleep is going.
Google pointed out how important sleep is (something we're all aware 0f). The company said the following on rest:
"Our phones have become great tools for making more informed decisions about our sleep. And by being informed about sleep habits, people can make better decisions throughout the day about sleep, which affects things like concentration and mental health."
The Sleep API is part of the Android Activity Recognition API, which also tracks other user activity like biking or walking using various metrics on the phone.
Google says that its API tracks sleep in two different ways:
- A ‘sleep confidence’, which is reported at a regular interval (up to 10 minutes)
- A daily sleep segment which is reported after a wakeup is detected
The API uses an on-device artificial intelligence model that uses its light and motion sensors as inputs to determine whether a user is actually asleep and for how long.
The main issue with sleep tracking on Android is battery life. Apps use detection algorithms to track when a user is sleeping. The problem, according to Google, is that "these detection algorithms are inconsistent between apps and when multiple apps independently and continuously check for changes in user activity, battery life suffers."
With Google's new sleep API, developers will be able to concentrate sleep detection processing in a way that uses less battery, which is exactly what users of sleep apps are looking for.
When Can Developers Use Google's Sleep API?
The new API is available for developers right now as part of the latest version of Google Play Services.
On top of releasing the API now, it sounds like Google isn't done working on improved sleep tracking. The company said, "We look forward to working more on this API and in this area in the future."
If you're an Android developer, check out Google's API documentation for a breakdown of everything you need to know to use it.