Activity Recognition may throw quite a few false positives as you, no matter how high you raise the confidence level. So if, for example, I would like to throw a notification when the user is driving I would need build some sort of state machine.
For example:
When I get IN_VEHICLE updates with CONFIDENCE > 70 for 30 seconds, I send a notification
or
When I get 3 consecutive IN_VEHICLE updates with CONFIDENCE > 70, I send a notification
There are different issues when implementing it though. Sometimes you get very frequent updates (2nd fails) or you vet very rare updates (1st fails).
How do go about designing this so that you have smoother transitions between states?
I think this tutorial - How to Recognize User Activity With Activity Recognition will help you. And, as mentioned in the tutorial, making your application context-aware is one of the best ways to offer useful services to your users.
In Handling Activity Recognition:
In the
onHandleIntent()method ofActivityRecognizedService, the first thing you do is validate that the receivedIntentcontains activity recognition data. If it does, then you can extract theActivityRecognitionResultfrom theIntentto see what activities your user might be performing. You can retrieve a list of the possible activities by callinggetProbableActivities()on theActivityRecognitionResultobject.
Source files used can be found in GitHub - Android-ActivityRecognition.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With