How to track distance via GPS on Android?

那年仲夏 提交于 2019-12-01 12:13:12

I am not an Android programmer but have implemented this functionality in my own embedded processor with far less processing capability than anything that runs Andriod.

This is nothing to do with the accuracy of a fix as determined by the GPS. If you have a stationary GPS receiver with "perfect" visibility of the sky and plot its reported position over time then you will see it wander around the true location, moving some metres an any direction. If you accumulate the distance travelled, in very small steps, around the true position you will end up with the distance travelled apparently taking you to the moon and back.

You need to set a movement threshold that is greater than the position accuracy of your GPS fix, and then only add in the distance travelled when you are sure that you have moved from the point at which you added in the last movement step.

You can call getAccuracy() on the Location object it gives you to check the accuracy. If your app needs to be real accurate, you can only count values with a high accuracy.

You can also call getProviders() on the LocationManager to check to see if you're getting coordinates from wifi, gps, or both, and ask the user to use their gps if it's not currently turned on so that you get more accurate points.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!