I am trying to detect a simple state of "walking" vs. "still" on Android. For this, I have implemented the ActivityRecognitionClient following the official Google codelab.
Essentially everything comes down to the request you make to the API, it's either:
ActivityRecognition.getClient(this).requestActivityUpdates(refreshRate, pendingIntent)
if you want to have control over how frequent the updates are made, or
ActivityRecognition.getClient(this).requestActivityTransitionUpdates(request, pendingIntent)
if you want to let the API control how frequent the updates are made.
And then getting the result
:
if (ActivityRecognitionResult.hasResult(intent))
val result = ActivityRecognitionResult.extractResult(intent).getMostProbableActivity()
My conclusion after trying the codelab final code, a couple of Google Play apps and my own implementation is that this API is just really bad, it doesn't "detect" the STILL
state unless it detected some other moving state like WALKING
or RUNNING
before, it detects moving states only close to when the state is actually finished as the devices stops moving, and it sends a lot of UNKNOWN
results.
Is my conclusion wrong in any way, and if not should I just listen for the Accelerometer sensor and process the raw x
, y
, z
data myself to recognize walking states?