Reputation: 2672
Is there any methods to automatically switch the android GPS_PROVIDER and NETWORK_PROVIDER, according to the current best provider?
Currently I'm using the following code to find the best provider and request the locationupdates using the best provider.
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
String provider = locationManager.getBestProvider(criteria, true);
locationManager.requestLocationUpdates(provider, 0, 1.0f, locationListener);
Suppose while starting this the user was inside a building, so the best provider at that time will be the NETWORK_PROVIDER. After some time he moves out, now the best provider willbe gps. But I had already started fetching locations using network provider. How to fix this?
Upvotes: 2
Views: 2729
Reputation: 104178
Follow the guidelines in the Obtaining User Location topic. You would need to listen to both providers and then decide, which one is offering more accurate results.
Upvotes: 1