We need know current user activity.
Using ActivityRecognitionApi we can get if user driving, walking, running, ride bicycle.

Android get information from all the sensors and analyse it using ActivityRecognitionApi.

Below simple sample how to implement it.

Please follow the steps:

1. Create android project in Android Studio.
2. Add compile ‘’ dependency in build.gradle:

3. Modify AndroidManifest.xml and add
“” uses-permission

4. Add ActivityRecognitionService which will handle the results.

6. Added Activity for visualisation.

Full source code here:

Download it from github


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.