Activity Recognition’s new Transition API makes context-aware features accessible to all developers

Posted by Marc Stogaitis, Tajinder Gadh, and Michael Cai, Android Activity Recognition Team

Phones are our most personal devices we bring with us everywhere, but until now it’s been hard for apps to adjust their experience to a user’s continually changing environment and activity. We’ve heard from developer after developer that they’re spending valuable engineering time to combine various signals like location and sensor data just to determine when the user has started or ended an activity like walking or driving. Even worse, when apps are independently and continuously checking for changes in user activity, battery life suffers. That’s why today, we’re excited to make the Activity Recognition Transition API available to all Android developers – a simple API that does all the processing for you and just tells you what you actually care about: when a user’s activity has changed.

Since November of last year, the Transition API has been working behind the scenes to power the Driving Do-Not-Disturb feature launched on the Pixel 2. While it might seem simple to turn on Do-Not-Disturb when car motion is detected by the phone’s sensors, many tricky challenges arise in practice. 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? With the Transition API, all Android developers can now leverage the same sets of training data and algorithmic filtering used by Google to confidently detect these changes in user activity.

Intuit partnered with us to test the Transition API and found it an ideal solution for their QuickBooks Self-Employed app:

“QuickBooks Self-Employed helps self-employed workers maximize their deductions at tax time by importing transactions and automatically tracking car mileage. Before the Transition API, we created our own solution to track mileage that combined GPS, phone sensors, and other metadata, but due to the wide variability in Android devices, our algorithm wasn’t 100% accurate and some users reported missing or incomplete trips. We were able to build a proof-of-concept using the Transition API in a matter of days and it has now replaced our existing solution, offering a more reliable solution that also reduced our battery consumption. The Transition API frees us up to focus our efforts on being the best possible tax solution,” say Pranay Airan and Mithun Mahadevan from Intuit.

Automatic mileage tracking in QuickBooks Self-Employed

Life360 similarly implemented the Transition API in their app with significant improvements in activity detection latency and battery consumption:

“With over 10 million active families, Life360 is the world’s largest mobile app for families. Our mission is to become the must-have Family Membership that gives families peace of mind anytime and anywhere. Today we do that through location sharing and 24/7 safety features like monitoring driving behavior of family members, so measuring activities accurately and with minimal battery drain is critical. To determine when a user has started or finished a drive, our app previously relied on a combination of geofences, the Fused Location Provider API and the Activity Recognition API, but there were many challenges with that approach including how to quickly detect the start of the drive without excessively draining battery and interpreting the granular and rapidly changing reading from the raw Activity Recognition API. But in testing the Transition API, we are seeing higher accuracy and reduced battery drain over our previous solution, more than meeting our needs,” says Dylan Keil from Life360.

Live location sharing in Life360

In the coming months, we will continue adding new activities to the Transition API to support even more kinds of context-aware features on Android like differentiating between road and rail vehicles. If you’re ready to use the Transition API in your app, check out our API guide.

Making Pixel better for Drivers

Posted by Marc Stogaitis and Tajinder Gadh, Software Engineers

Driving is an essential part of our daily activities. So at Google we spend a
lot of time thinking how we can make Android devices better and safer for our
users. How we can prevent distracted driving and together build an open
ecosystem to enable safety first smartphone experiences.

Recently we launched Driving Do-Not-Disturb on the newly announced Pixel 2
generation of devices. Once enabled, Driving Do-Not-Disturb automatically puts
your device into a do not disturb mode while driving. During this mode any
incoming messages and notifications are silenced while you can still receive
incoming calls, navigation directions and voice interactions using a connected
Car bluetooth. The product is designed to limit distractions during driving
while at the same time not getting in the way so users can continue to use
navigation or other similar apps with minimal friction.

Behind the scenes, it uses AI powered on-device Activity
Recognition
that detects when a person is driving using low power signals
from multiple sensors, bluetooth and WiFi. Activity Recognition uses the Android
Sensor Hub to ensure low latency, low power and accurate driving detection.

This is a next step in our journey, but we are far from done. Early next year
we are introducing the Activity Recognition Transition API, which is the same
API used by Driving Do Not Disturb to build distraction-free driving
experiences.

We appreciate the feedback, and will continue to listen to your feedback as the
product evolves.

If you have questions about setting up the Driving Do-Not-Disturb, check out our
Help Center.