Search code examples
androidandroid-gpson-location-changed

Best way to track Android phone in a moving car


I am creating an app which send GPS coordinates once location is change. I need to send data only when the vehicle is moving. How can I get to know this. I got two options

  1. Using onLocationChanged, getSpeed();
  2. Using the Accelerometer

What is the best way to do this?


Solution

  • onLocationChanged is probably your best bet. This can be quite heavy on the battery, so be careful with your frequency. If im not mistaken, the accelerometer is used to detect movement along 3 axis, like device rotation. A moving car doesnt sound like an apporpriate use case.