【发布时间】:2012-02-14 17:22:30
【问题描述】:
我正在使用LocationListener 并且返回的位置始终具有轴承为 0.0
我还有什么需要做的吗?
我还注意到,在 4.0.3 更新中,我很少报告速度。现在我只得到位置和精度/高度
public void onLocationChanged(Location loc)
{
Log.d(LOG_TAG, "onLocationChanged");
Position position = new Position();
position.PositionGKey = UUID.randomUUID();
position.GPSTime = new Date(loc.getTime());
position.DeviceTime = new Date();
position.Latitude = loc.getLatitude();
position.Longitude = loc.getLongitude();
position.Altitude = loc.getAltitude();
position.Speed = loc.hasSpeed() ? loc.getSpeed() * 2.23693629 : 0;
position.Accuracy = (int)loc.getAccuracy();
position.Bearing = loc.hasBearing() ? loc.getBearing() : 0;
// There was cases with speed reported 1000+. Just make it real here, round of obvious errors.
if (position.Speed > 120)
{
position.Speed = 0.0;
}
PositionData.InsertPosition(getApplicationContext(), position);
}
【问题讨论】:
-
请发布有关您如何获得位置的相关代码...我们中的一些人可能会使用巫术,但我们绝对不是猜测者:)
-
已发布代码。关键是 4.0.3 的行为不同。我几乎没有得到速度,刚才我添加了轴承,但从来没有看到它被记录下来..
-
是在使用 GPS 或 NETWORK 提供商时吗?