Reputation: 547
I am a new Android developer. I am working on a small project that works with sensors and services. I want to detect of the user is moving in the room or is stationary. in order to do this do I need to use accelerometer or GPS.
Upvotes: 1
Views: 2621
Reputation: 1243
@umair's answer is correct but ActivityRecognitionApi interface was deprecated and you should use ActivityRecognitionClient for your apps and update your existing app if you are using old ActivityRecognitionApi
Upvotes: 1
Reputation: 968
You can achieve this by Google's ActivityRecognitionApi API. It tells you about user's current activity, such as walking, driving, or standing still.
You can check out sample code here: ActivityRecognition
The Activity Recognition API is built on top of the sensors available in a device. Device sensors provide insights into what users are currently doing. However, with dozens of signals from multiple sensors and slight variations in how people do things, detecting what users are doing is not easy.
The Activity Recognition API automatically detects activities by periodically reading short bursts of sensor data and processing them using machine learning models.
Upvotes: 1