Google's Transition API allows developers to access context-aware features
To help preserve the battery on Android handsets, Google has introduced the Activity Recognition Transition API. Available to all Android developers, the API tells developers when a user has changed his activity. It has been used on the Google Pixel 2 to run the latter's Driving Do-Not-Disturb feature; Do-Not-Disturb is automatically enabled once the phone determines that it is in motion (inside a car). But the reason for motion and lack of motion can be hard for a phone to understand; did the motion stop because the user reached his destination and parked the car, or did the driver merely stop at a red light? The Transition API uses training data and algorithms "to confidently detect these changes in user activity."
Google partnered with Intuit to test the Transition API on the QuickBooks Self-Employed app. Before the test, Intuit employed GPS, phone sensors, and other metadata to automatically track mileage on the app for tax purposes. Intuit says that using the Transition API offers a more reliable way to automatically track mileage, while reducing battery consumption on a handset.
Similar results were achieved by the Life360 app, which used the Fused Location Provider API and the Activity Recognition API to keep track of the driving behavior of family members. But determining the start of a trip would drain the battery on a user's phone, among other problems. Switching to the Transition API improved the accuracy of the app and bolstered battery life.
Google says that it will continue to add new context-aware features to Transition API, including the ability for an Android handset to determine if it is in a car or riding on a train.