Location.getTime()始终返回时间戳而不是毫秒

时间:2014-05-30 15:54:51

标签: android gps geolocation

我正在LocationManager.requestLocationUpdates()使用LocationManager.GPS_PROVIDER跟踪GPS位置并注册LocationListener

我的问题:

所有经过测试的设备(Sony neo,Sony active,Moto G)都会生成LocationgetTime()中没有分数的对象:

<trkpt ...><time>2014-05-24T10:24:59.000Z</time></trkpt>
<trkpt ...><time>2014-05-24T10:25:00.000Z</time></trkpt>
<trkpt ...><time>2014-05-24T10:25:01.000Z</time></trkpt>
<trkpt ...><time>2014-05-24T10:25:02.000Z</time></trkpt>
<trkpt ...><time>2014-05-24T10:25:03.000Z</time></trkpt>

由于我正在计算速度,倾斜和与气压高度合并,1s(1000ms)分辨率太不精确了。而且我不相信,.000处的修补程序完全

我的问题:

最好将System.currentTimeMillis()作为我的跟踪点的时间戳,或者GPS定位通常远​​远落后于“实时”,计算出的位置实际上是过去的那些(落后几秒)?

说明:

1 个答案:

答案 0 :(得分:0)

根据我的经验,System.currentTimeMillis()是一种更好的获取时间戳的方法,而这正是我在我的应用中所做的。但是,请注意,如Android开发者网站上所述,System.currentTimeMillis() Returns the current time in milliseconds since January 1, 1970 00:00:00.0 UTC所以它实际上取决于您想要使用它的内容。正如我所提到的,我发现它比其他形式的时间戳更可靠,它可能最适合你的情况。