If I set any ACCURACY to criteria, it takes long time to LocationManager to start updating location:
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
provider = locationManager.getBestProvider(criteria, true);
locationManager.requestLocationUpdates(provider, 0, 0, this);
If I remove ACCURACY flag, it starts immediately but sometimes not accurate.
How can I make it start updating immediately and with good accuracy?
First, create a Location Manager object by calling the getSystemService() method and LOCATION_SERVICE as an argument. Call getBestProvider() to get the location in the form of a string. Now the provider to getLastKnownLocation() as an argument to get the location.
This class provides access to the system location services. These services allow applications to obtain periodic updates of the device's geographical location, or to be notified when the device enters the proximity of a given geographical location.
You can get your accuracy info from Location. getAccuracy() or from NMEA data. Once you've started getting fixes it won't take much time. Time to first fix can be 30 seconds to 15 minutes.
Unfortunately, no way.
If you use ACCURACY_FINE
, you will use GPS only, but GPS have "cold start" effect. It means that if you device not used GPS long time, it needs a lot of time for connecting with satellites and download almanac and ephemeris. You can't change this behavior.
If you don't use ACCURACY_FINE
, you will use both GPS and network (mobile, wi-fi) signals. So you will receive quick first position from network, because they don't have "cold start" effect, but accuracy of this method is low. When your GPS module will ready, you will start receive updates from it too.
If you care only about accuracy and not things like bearing or altitude I suggest switching to the new fused provider in the LocationClient
API from Google.
It is very quick to get the first fix, more accurate than network based and doesn't depend on GPS.
It requires a bit more setup then the built-in LocationManager
, so you may read this training article: http://developer.android.com/training/location/receive-location-updates.html
I suspect that at least with ACCURACY_FINE
, it's waiting to get an initial GPS fix. You may find that if you've already got GPS turned on for another reason (e.g. if you're in the middle of navigation) that it starts reporting immediately.
It can take a while to get a GPS fix - I think it's just a natural part of how GPS works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With