我正在通过 LocationManager.requestLocationUpdates()
使用 LocationManager.GPS_PROVIDER
跟踪 GPS 位置并注册 LocationListener
.
I'm tracking GPS locations with LocationManager.requestLocationUpdates()
using LocationManager.GPS_PROVIDER
and registering a LocationListener
.
我的问题:
所有经过测试的设备(Sony neo、Sony active、Moto G)都会生成 Location
对象,这些对象在其 getTime()
中没有几分之一秒:
All tested devices (Sony neo, Sony active, Moto G) produce Location
objects which do not have fractions of a second in their getTime()
:
<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>
当我计算速度、倾斜和与气压高度合并时,1 秒(1000 毫秒)的分辨率太不精确了.而且我不相信所有的修复都是完全在.000
.
As I'm calculating speed, incline and merge with barometic altitude, 1s (1000ms) resolution is way too imprecise. And I do not believe, that the fixes are all exactly at .000
.
我的问题:
最好将 System.currentTimeMillis()
作为我的跟踪点的时间戳,或者 GPS 定位通常远远落后于实时",并且计算出的位置实际上是来自过去(落后几秒)?
Is is better to take System.currentTimeMillis()
as the timestamp for my track-points, or is the GPS fix generally far behind "real time" and the calculated positions are actually those from the past (several seconds behind)?
备注:
根据我的经验,System.currentTimeMillis()
是一种更好的获取时间戳的方法,这就是我正在做的事情我的应用程序.但是,请注意,如 android 开发者网站所述,System.currentTimeMillis() 返回自 1970 年 1 月 1 日 00:00:00.0 UTC 以来的当前时间(以毫秒为单位)
所以它真的取决于什么你想用它.正如我所提到的,我发现它比其他形式的时间戳更可靠,它可能最适合您的情况.
In my experience, System.currentTimeMillis()
is a much better way to take timestamps, and it is what I am doing in my app. However, please be advised that, as stated on the android developer site, System.currentTimeMillis() Returns the current time in milliseconds since January 1, 1970 00:00:00.0 UTC
so it really depends on what you want to use it for. As I mentioned though, I found it to be more reliable than other forms of timestamps and it is probably best suited for your case.
这篇关于Location.getTime() 总是返回没有毫秒的时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!