You are getting just the last known location. You should request location updates from the LocationManager
. Use LocationManager.getLocationUpdates
.
On your LocationListener
on the onLocationChanged(Location location)
method, you can check on the Location
object, how accurate this location is, like this :
float accuracy=location.getAccuracy();
then, if this Location
is accurate enough for you, you can stop receiving location updates from the LocationManager
using removeUpdates()
, and use the received Location
. If the Location
is not accurate enough, you can wait for a more precise Location
, and stop the updates latter on.