【发布时间】:2014-11-08 11:21:37
【问题描述】:
我在主要活动中有以下代码:
LocationManager mlocMan = (LocationManager)getActivity().getSystemService(Context.LOCATION_SERVICE);
if (mlocMan.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
LocationListener mlocListener = new LocationManagerHelper(...);
mlocMan.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,mlocListener);
}
在位置监听器中我有这个:(theAccuracy 被初始化为 -1)
if (theAccuracy == -1 || theAccuracy > loc.getAccuracy()) {
theAccuracy = Math.round(loc.getAccuracy());
latitude = loc.getLatitude();
longitude = loc.getLongitude();
}
updateTimes++;
if (updateTimes == 3) {
mLocMan.removeUpdates(this);
updateTimes = 0;
//get address for location
theAccuracy = -1;
}
意思是,在从 GPS 更新 3 次位置后,获取最佳准确位置并获取其地址。在模拟器上,我得到了 20m 的固定精度(我使用 DDMS 发送 long/lat),但这不是现实生活,所以我尝试使用我的设备,而第一次(3 个请求)给了我确切的地址(当场) 40m 精度,下一个有时更准确,但地址就在附近。我得到的最佳精度是 29m(发生一次),大部分时间都在 30 以上。这是我的 GPS(LG G3)的问题,还是有任何其他想法可以在 3-4-5 请求后使事情更准确?
【问题讨论】: