Reputation: 656
Please tell me one thing
Here are two variation of requesting location updates
Criteria mFineCriteria = new Criteria();
mFineCriteria.setAccuracy(Criteria.ACCURACY_FINE);
mFineCriteria.setHorizontalAccuracy(Criteria.ACCURACY_HIGH);
mFineCriteria.setBearingAccuracy(Criteria.ACCURACY_HIGH);
mFineCriteria.setBearingRequired(true);
if I do
String provider = mLocationManager.getBestProvider(mFineCriteria, true);
mLocationManager.requestLocationUpdates(provider, 1000, 1, mLocationListener, null);
Then my GPS starts and everything is ok. But if I just request updates with this criteria,
mLocationManager.requestLocationUpdates(1000, 1, mFineCriteria, mLocationListener, null);
then I'm get results from fused location provider and gps doesn't work.
EDIT
Please tell, why requesLocationUpdates doesn't use GPS if it is a best available provider for the same criteria
Upvotes: 3
Views: 2653
Reputation: 2987
I think that you can get information about which provider was selected
String provider = locationManager.getBestProvider(criteria, false);
Log.i(TAG, "AllProviders = " + locationManager.getAllProviders().toString());
Log.i(TAG, "Provider [" + provider + "] best criteria.");
Monitor:
AllProviders = [passive, gps, network]
Provider [gps] best criteria.
See also https://stackoverflow.com/a/23425606/345810
Upvotes: 0
Reputation: 2024
Just looking in the same problem somewhat, and this might explain it for you:
public String LocationManager.getBestProvider (Criteria criteria, boolean enabledOnly)
Added in API level 1 Returns the name of the provider that best meets the given criteria. Only providers that are permitted to be accessed by the calling activity will be returned. If several providers meet the criteria, the one with the best accuracy is returned. If no provider meets the criteria, the criteria are loosened in the following sequence:
Note that the requirement on monetary cost is not removed in this process.
Upvotes: 1