Last year, Google detailed how the Pixel 2’s Driving Do-Not-Disturb mode can intelligently silence incoming notifications when you’re in a moving vehicle. This feature is powered by the Activity Recognition Transition API that is now available to all developers and apps.
Android’s Activity Recognition API works by processing a device’s sensor data through machine learning models without draining resources or battery life. The Transition API is specifically focussed on detecting when users start or stop an activity.
Google notes that this is not a simple problem, especially in the case of driving:
How can you tell if stillness means the user parked their car and ended a drive or simply stopped at a traffic light and will continue on? Should you trust a spike in a non-driving activity or is it a momentary classification error?
To arrive at this point, the company trained machine learning models and used algorithmic filtering “to confidently detect these changes in user activity.” Available to all developers, it can detect when users are not moving, walking, running, on a bicycle, or in a vehicle. It takes care of all the processing work and simply informs apps when a user’s activity has changed.
With this API, Google hopes that developers will no longer have to rely on bespoke solutions that are not as battery efficient and require time and effort to develop. In the future, Google will add more context aware features like differentiating between road and rail vehicles.