我使用了检测设备位置变化的onLocationChanged
方法。LocationListener
在requestLocationUpdates
方法中,我设置了最小时间 = 5 秒和最小距离 = 2 米,但requestLocationUpdates
即使我的设备根本没有移动(静止放置),方法也会给我更新。所以请告诉我的代码有什么问题?
这是我的代码:
public class LocationDetector implements LocationListener {
@Override
public void onLocationChanged(Location location) {
Log.d("GPS: ",location.getLatitude()+", "+location.getLongitude());
}
.
LocationManager manager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
.
manager.requestLocationUpdates("gps", 5000, 2, new LocationDetector());