Does LocationManager have the ability to change, from example, from GPS to a more course provider, should the device lose its GPS signal?
As far as I know it's not, but I'm not 100% sure, so I need to ask
(The reason I ask, is I'm tempted to make my own LocationManagerManager that handles these sorts of problems. I might have it accept multiple Criteria objects which are tried in some sort of order under various circumstances that the traditional LocationManager isn't flexible enough for. But I don't want to be reinventing the wheel, eg if Google have handled this in some method/class unknown to me).
Thanks
Not that I'm aware of: your option is probably the best idea. Register for all the available providers and then return the best available Location value.
Yeah, it's already available. Just google it, u must get it. Check this function out :
`
public boolean testProviders() {
Log.e(LOG_TAG, "testProviders");
String location_context = Context.LOCATION_SERVICE;
locationmanager = (LocationManager) getSystemService(location_context);
List<String> providers = locationmanager.getProviders(true);
for (String provider : providers) {
Log.e(LOG_TAG, "registering provider " + provider);
listener = new LocationListener() {
public void onLocationChanged(Location location) {
// keep checking the location - until we have
// what we need
//if (!checkLoc(location)) {
Log.e(LOG_TAG, "onLocationChanged");
locationDetermined = checkLoc(location);
//}
}
public void onProviderDisabled(String provider) {
}
public void onProviderEnabled(String provider) {
}
public void onStatusChanged(String provider, int status,
Bundle extras) {
}
};
locationmanager.requestLocationUpdates(provider, 0,
0, listener);
}
Log.e(LOG_TAG, "getting updates");
return true;
}
`
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.