Android GPS模拟器轨迹
我使用android emulator ddms使用gpx文件模拟移动。gpx文件中大约有1000个条目。然而,我发现我的onLocationChanged方法在整个文件过程中只被触发了几次。我的代码如下Android GPS模拟器轨迹,android,android-emulator,Android,Android Emulator,我使用android emulator ddms使用gpx文件模拟移动。gpx文件中大约有1000个条目。然而,我发现我的onLocationChanged方法在整个文件过程中只被触发了几次。我的代码如下 LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); locationManager.requestLocationUp
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, myListener);
myListener = new LocationListener(){
public void onLocationChanged(Location location){
double mylat = location.getLatitude();
double mylon = location.getLongitude();
...
}
...
}
我对requestLocationUpdates设置为1000的理解是,如果位置距离前一个位置超过1m,它应该每1秒请求一次位置更新。这是正确的吗?如果是这样,为什么我只能从gpx文件中检索几个lat/lon对?我不是要找回将近一千个吗?(GPS数据来自运行中的人,因此有恒定的运动。)使用gpx、kml或手动输入lat/long坐标的模拟器位置,我运气不太好。根据我的经验,在requestLocationUpdates中设置位置和距离最小值在实际硬件上效果很好,但在模拟器中效果不佳
如果使用gpx文件只是出于测试目的,请尝试将时间和位置约束设置为0和0,看看它现在是否在emulator中注册了所有1000个点。这实际上非常有用。当我把它设为0,0时,我得到了所有的分数。所以对于阅读本文的其他人:遵循马克的建议。