有时我从GPS收到无效/错误的位置。我不是说米,而是几公里。有时超过300公里。我搜索了很多,仍然没有找到解决方案。
以下是今晚的一个例子:
09-13 21:33:29.788 V / TEST:onLocationChanged GPS 21:33:28 13/09/2014,XX.603674,XX.154188,20.0 09-13 21:33:31.338 V / TEST:onLocationChanged GPS 21:33:30 13/09/2014,XX.603633,XX.154111,20.0 09-13 21:35:24.061 V / TEST:onLocationChanged GPS 21:35:25 13/09/2014,XX.567266,XX.031885,10.0 09-13 21:36:16.226 V / TEST:onLocationChanged GPS 21:36:17 13/09/2014,XX.603408,XX.153793,20.0
这次不到12公里。但有些时候非常非常遥远。我的设备是三星GT-I9100(4.1.2)。
这是代码(我没有测试location.hasAccuracy,因为在这种情况下没有区别):
LocationListener gpsLocationListener = new LocationListener() {
@Override
public void onLocationChanged(Location location) {
if (location == null) return;
Log.v(TAG, "onLocationChanged GPS " + getCurrentTime(location.getTime(), false) + ", " +
String.format("%.6f", location.getLatitude()) + ", " + String.format("%.6f", location.getLongitude()) + ", " + String.format("%.1f", location.getAccuracy()));
}
public void onStatusChanged(String provider, int status, Bundle extras) {}
public void onProviderEnabled(String provider) {}
public void onProviderDisabled(String provider) {}
};
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30, 5, gpsLocationListener);
我做错了什么????