代码是这样的:
private LocationManager locationManager1;
private LocationManager locationManager2;
......
locationManager1 =(LocationManager)getSystemService(Context.LOCATION_SERVICE);
locationManager2 =(LocationManager)getSystemService(Context.LOCATION_SERVICE);
....
locationManager1.requestLocationUpdates("GPS",30000, 0, LbsClient2ServerDemo.this);
locationManager2.requestLocationUpdates("GPS",0, 0, LbsClient2ServerDemo.this);
......
当两个locationManager对象调用requestLocationUpdates(...)
时,
locationManager1 和 locationManager2 有 GPS 提供商。
locationManager1对象正在搜索卫星,但是locationManager2即将到来,locationManager2.requestLocationUpdates()会中断locationManager1吗?也许会导致GPS定位速度变慢?
最佳答案
您不必创建两个 LocationManager 对象。
使用这种方式获取所有可用的提供程序并从他们那里获取修复,并且 onLocationChanged()
中返回的修复将是 LocationManager 可以获得的更好的修复。
List<String> providers = locationManager.getProviders(true);
for (String provider : providers) {
locationManager.requestLocationUpdates(provider, 0, 0, this);
}
关于android - 当两个locationManager对象调用requestLocationUpdates(...)时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9578262/