Google Play Services provides an ActivityRecognitionApi
that lets you detect various user activities (via DetectedActivity
) such as if the user is walking or running.
Is it possible to mock these activities for development and testing purposes?
Yes, it's possible, but only on the emulator (or a rooted device).
For example, to simulate the walking activity run:
adb root
adb shell am broadcast -a com.google.gservices.intent.action.GSERVICES_OVERRIDE -e 'location:mock_activity_type' 'WALKING'
And then restart Google Play Services (or restart the device):
adb shell ps -A | grep com.google.android.gms.persistent | awk '{print $2}' | xargs adb shell kill