我正在通过 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() 总是返回没有毫秒的时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
帮助从 iPhone 中的纬度和经度计算 X 和 YHelp calculating X and Y from Latitude and Longitude in iPhone(帮助从 iPhone 中的纬度和经度计算 X 和 Y)
使用 GPS 获取用户的当前位置Get user#39;s current location using GPS(使用 GPS 获取用户的当前位置)
requestLocationUpdate() 抛出的 IllegalArgumentExceptionIllegalArgumentException thrown by requestLocationUpdate()(requestLocationUpdate() 抛出的 IllegalArgumentException)
LocationManager 的 getLastKnownLocation 有多可靠,多久更How reliable is LocationManager#39;s getLastKnownLocation and how often is it updated?(LocationManager 的 getLastKnownLocation 有多可靠,多久更新
CLLocation 返回负速度CLLocation returning negative speed(CLLocation 返回负速度)
如何检测位置提供者?GPS 或网络提供商How to detect Location Provider ? GPS or Network Provider(如何检测位置提供者?GPS 或网络提供商)