robguinness
robguinness

Reputation: 16656

getLastKnownLocation only updates when position changes ~50 m. Why?

In using the getLastKnownLocation() method of LocationManager, I noticed that the position which it obtains only changes if I move approximately 50 m.

This is despite the fact that GPS visibility is high and positioning error should be on the order of 5 m in the areas where I tested it. I was wondering if there is any "distance change" constraint built into getLastKnownLocation(), such that it only updates its saved location if the position changes by a certain amount [much like you can place a distance constraint on requestLocationUpdates()].

If so, does anyone know what that distance constraint is exactly?

Thanks!

Upvotes: 1

Views: 1963

Answers (1)

Michell Bak
Michell Bak

Reputation: 13242

The getLastKnownLocation() method will only return the location of the last GPS fix - regardless of whether it was obtained by your application or a third party application. It doesn't return your current location and it doesn't change if you move approximately 50 meters - at least not if no other applications are using the GPS.

It should be used to give an approximated location of the user or as a "placeholder" until fresh data is obtained.

See this blog post for more details on this: http://android-developers.blogspot.com/2011/06/deep-dive-into-location.html

Reto Meier, a member of the Android developers team, also gave a speech at Google I/O last year in which he talked about the use of location services, including getLastKnownLocation().

Upvotes: 3

Related Questions