Reputation: 5501
I set up my location manager by executing
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Then I call have a update button on my app so that when it is pressed, the I will call executing the following line
Location loc = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER)
However, the location that I get is always the same one, even after I held the device and walk straight for 20 meters and then wait for 10 minutes!
May I ask if I missed anything?
Thanks!
Upvotes: 1
Views: 2136
Reputation: 12048
The getLastKnownLocation()
method returns the last GPS location acquired. If you don't start GPS location acquisition to have it acquiring new locations, the value returned by this method will always be the same old value.
You will need to:
lm.requestLocationUpdates()
onLocationChange()
listener to receive the new locationsandroid.permission.ACCESS_FINE_LOCATION
in AndroidManifest.xml
fileregards
Upvotes: 3