• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps proper provider parameter for requestLocationUpdates

shroge

Lurker
I'm fairly new to android and I'm trying to create a location based app. I'm currently using the LocationManager.GPS_PROVIDER as follows:

Code:
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 20000, 1, locationListener);
Does the LocationManager.GPS_PROVIDER contain the best provider available? I checked the android online documentation for LocationManager and can't seem to find anything definitive on where the value of GPS_PROVIDER comes from. I've noticed that I can manually get the best provider by the following:

Code:
Criteria criteria = new Criteria();
bestProvider = locationManager.getBestProvider(criteria, false);
Which way to get the provider is considered the correct way?

I was also wondering about how the location update mechanism deals with someone who is moving and passes from one best gps provider to another. For instance if someone is traveling on a train/car that goes a fairly long distance. Is the original requestLocationUpdates updated with the new best gps provider? If not, I suppose the best provider should be checked in onLocationChanged and then a new requestLocationUpdates given.

Thanks for the help...
 
I use this. It works well: fast and accurate.

Code:
Criteria locationCriteria = new Criteria();
locationCriteria.setAccuracy(Criteria.ACCURACY_FINE);
				
lm.requestLocationUpdates(lm.getBestProvider(locationCriteria, true), 0, 0, currentLocationListener);
 
Back
Top Bottom