Google has launched a Sleep API on Android that makes our phone recognize when we are asleep and communicate this to the device’s wellness applications.
This sleep API, as part of the broader activity recognition API, allows analyzing the light sensors and the movement of our phone with an artificial intelligence model to generate information so that the phone recognizes when we are asleep.
With this new tool, Google wants to avoid that developers have to “spend valuable development time combining sensor signals to determine when the user has started or ended activities such as sleeping,” according to Google.
This sleep API repeats up to two types of information — on the one hand, it establishes a query pattern of our sleep that is saved at regular intervals of up to 10 minutes. On the other hand, a log of a daily sleep segment can be created that is archived after you wake up. With this information, in essence, the phone finds out when you are going to sleep and notifies the relevant applications.
These detections are made within the mobile; it does not connect to any server to use external applications.
The method used until now was very inefficient since the detection algorithms used until now were inconsistent between applications. These verified the information independently and continuously in the face of changes in user activity, which directly affects the battery. In this case, it will be the API that will make the sensors collect that information and report it to other applications.
This type of measurement is already carried out by applications such as Sleep as Android. In fact, Google has collaborated with the creator of this app to ensure that the new API does not have excessive battery consumption.
The new API will be available in the latest version of Google Play Services, and it will allow developers to create new applications to control users’ sleep.
Of course, users will have to agree to use this feature and grant permission for this physical activity recognition feature before the apps access the data.