[英]LocationManager change provider on the fly
Does LocationManager have the ability to change, from example, from GPS to a more course provider, should the device lose its GPS signal? LocationManager是否有能力从GPS更改为更多的课程提供商,设备是否应该丢失其GPS信号?
As far as I know it's not, but I'm not 100% sure, so I need to ask 据我所知不是,但是我不确定100%,所以我需要问
(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). (我问的原因是,我很想让自己的LocationManagerManager处理这类问题。我可能会让它接受多个Criteria对象,这些对象在各种情况下会以某种顺序尝试,而传统的LocationManager不灵活但是我不想重新发明轮子,例如,如果Google用我不知道的某种方法/类来处理这个问题)。
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;
}
` `
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.