I am trying to locate user's device to get its current location with coarse method. The problem is that I can only accept a location with accuracy of 1000m, my code like this:
public void onLocationChanged(Location location) {
currentLocation = location;
if(location.hasAccuracy())
{
if(location.getAccuracy() < 1000)
{
locationManager.removeUpdates(this);
callback(); //do callback here
}
}
}
But what if the network is not good and I can not get the location with that accuracy? I may want to accept the latest location I got if I have requested its location for some time, like 1 minute.
Then how can I control the request time, for example, 1 minute, if it did not get the accurate location until then, I will stop it and then accept the latest location I have got if exist.