Programming Google Map Android
Comparing two locations for accuracy in Android

If you are developing a android application which uses android Location Service and you need to find best estimated location by comparing two locations, where one location is the currently obtained location and other is from the location fix then this post contains answer to your question. The below mentioned code contains a method isBetterLocation which will compare two locations and will return true if current location is more accurate than location fix. You might expect that the most recent location fix is the most accurate. However, because the accuracy of a location fix varies, the most recent fix is not always the best.

isBetterLocation method follows following criteria for choosing location fixes, you vary this criteria depending on the use-cases of the application and field testing.

  • Check if the location retrieved is significantly newer than the previous estimate.
  • Check if the accuracy claimed by the location is better or worse than the previous estimate.
  • Check which provider the new location is from and determine if you trust it more.

Related Post

Leave a Reply