Afzal
Afzal

Reputation: 367

How to detect whether location is valid or not in android application?

I have got two location listeners in my app, GPS and Network. They work fine except sometimes while traveling, the location name (returned from Geocoding API) shows very incorrect location for a small period of time (like a continent away).

Is there a way we can validate that the returned location (from location API and Geocoding API) is valid and only then show it to the user?

Upvotes: 0

Views: 1990

Answers (1)

David Brown
David Brown

Reputation: 3061

I tend to show the user the reported accuracy so they know within how many meters the reported position is. And then I only attempt to geocode an address if the accuracy is within a certain limit.

When you get your Location object, just call getAccuracy() on it to check.

Upvotes: 3

Related Questions