I am creating an app that alerts user if he has been stationary for a few minutes(say 10).
I find it easy to detect motion, using LocationListener which triggers a function if device moved a certain distance.
However, I want something different. I want a function to be called if the device did not move for a certain duration of time.
How I achieve this?
You could easily set a timer and when the LocationListener fires, reset the timer to zero. If the timer reaches 10 minutes, then you know that the user hasn’t moved. The downside to this approach is that the timer must continue to run, so you will need to install as a service.
http://developer.android.com/reference/java/util/Timer.html