Android apps that have to run in the background like sleep-trackers have had a rough time. They suffer inconsistent and unreliable background app limitations across different Android versions, which can interfere with how the apps work at a very fundamental level. Thankfully, Google is rolling out a brand new Sleep API built right into Google Play Services. It sounds like it should fix that issue — at least, for sleep-tracking apps, anyway.
The API is built into the existing Activity Recognition suite, which (if you allow it) can automatically pick up on the things you’re doing based on the device sensors. That’s how things like Google Fit can determine whether you’re biking, walking, or driving when it comes to tracking physical activity. Google already uses the Sleep API internally for the Google Clock’s bedtime mode.
So what does this change mean for you — isn’t an API some technical thing you as an end-user don’t need to worry about? Well, it may actually have a measurable impact with some big benefits.
See, previously, these sleep-tracking apps have had to run their own detection algorithms, watching device sensors with their own trained models and triggers to try to estimate when you’re sleeping. That means they’re running continuously in the background to do those things. Like I said earlier, some smartphone makers adjust Android itself in a way that outright breaks this behavior, and Google has already said it won’t really do anything to fix that. But this API means they won’t have to anymore; it’s all just built right in. Smartphone manufacturers won’t mess with how Play Services works because that’s something Google might actually get upset about, so developers can rely on this new API to work.
It also means sleep-tracking apps will make less of a dent in your battery life going forward. If Play Services is already doing all this stuff in the background, having an app running in the background and doing the same things in parallel is redundant and wastes power. This is simpler and more efficient. Since many of these apps need the phone on your bed next to you to work, and since it can be awkward and tangle-prone to plug them in that way, this means your phone is that much more likely to last until the morning.
There’s one last reason we think this will make a difference: Urbandroid, the makers of Sleep as Android, are involved. That’s a big deal because Urbandroid is also behind Don’t Kill My App!, and they’ve been tracking the effect that manufacturer background app “optimizations” have on developers. If they’re involved, odds are this is change is a good thing. We’ve reached out separately to Urbandroid for more information and their take on the news as well, though a statement was included together with Google’s announcement:
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.
It remains to be seen how Google’s new Sleep API will actually perform in practice. Many of these sleep-tracking apps consider their detection methods something of a trade secret, often an advertised benefit that their app has over someone else’s. Still, I’m optimistic that Google’s API should deliver high-quality data to developers. And for us consumers, that means better sleep-tracking apps with better battery life and fewer unexplained issues.