androidlocation

Android while driving logic


I want to practice my Android development skills by creating an app which sets 2 locations. To make it more interesting, I only want to set them while I am driving / arrived. The first, startLocation is created when the user is faster than 19km/h. I get that at the onLocationChanged Event with FusedLocationApi from Google.

But obviously, there is the question when to create the endLocation. My solution for that would be to run a handler if the speed is less then 19km/h and wait 2 minutes. If the speed doesn't get faster then 19km/h within 2 minutes the endLocation get set.

Having said that I would like to hear some other solutions for that problem.

Thank you


Solution

  • That's the solution I used when I wrote a similar app 5 years ago. Since then Google came out with activity detection, which determines if a user is walking, biking, or driving. I'd just use that now.