Android ActivityRecognition services - running in the background?

I am developing an application that will track user activity throughout the day, and when a specific action (i.e. driving) is detected, a notification will be triggered. Google Play services now support ActivityRecognition, which makes the task easier and more efficient (instead of messing with GPS / other sensors).

My question is: can I make activity recognition work completely as a service? From my reading, it turns out that recognition should be initiated by Activity (connecting to Play Services, initiating intent, etc.). This is great when the user interacts with the application, but if the phone restarts or the activity is closed in another way, I need the service to continue to run in the background so that it can continue to monitor user activity and send pop-up notifications. Is there any way to do this? If so, are there any examples of this online? Thanks in advance!

+4
source share

All Articles