Android Sensor Timestamp 参考时间
我正在从 SensorEvent 数据中读取时间戳值,但无法计算出这些值的参考时间。 Android 文档只是说“事件发生的时间(以纳秒为单位)” 举个例子:
我当前的 Android 设备日期,2011 年 10 月 14 日 23:29:56.421 (GMT+2)
System.currentTimeMillis * 1000000 (nanosec) = 1318627796431000000 (即好的)
sensorevent.timestamp(纳秒)= 67578436328000 = 19 小时 46 分钟 ????
你可以帮我吗?
谢谢
I'm reading timestamp values from SensorEvent data but I can't work out the reference time for these values. Android documentation just says "The time in nanosecond at which the event happened" As an example:
My current Android device date, October 14th 2011 23:29:56.421 (GMT+2)
System.currentTimeMillis * 1000000 (nanosec) = 1318627796431000000 (that's ok)
sensorevent.timestamp (nanosec) = 67578436328000 = 19 hours 46 min ????
May you help me?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看来您正在处理的是自操作系统启动以来的纳秒数,也称为“正常运行时间”。
有关此问题的更多信息:http://code.google.com/ p/android/issues/detail?id=7981
我应该补充一下链接的问题SensorEvent.timestamp 到绝对 (utc) 时间戳? 处理相同的问题,并且在哪里我找到了答案。
It appears that what you are dealing with is the number of nanoseconds since the operating system started, also known as "uptime".
Further info on the issue: http://code.google.com/p/android/issues/detail?id=7981
I should add that the linked question SensorEvent.timestamp to absolute (utc) timestamp? deals with the same issue and is where I found the answer.
我知道这是一个非常古老的问题,但是,我也在努力将
SensorEvent.timestamp
转换为人类可读的时间。因此,我在这里写下我到目前为止所理解的内容以及我如何将其转换,以便从你们那里获得更好的解决方案。任何意见都将受到欢迎。据我了解,SensorEvent.timestamp是自设备启动以来经过的时间。所以我必须知道设备的正常运行时间。所以如果有一个返回设备启动的API,那就很容易了,但是,我还没有找到。
因此,我使用 SystemClock.elapsedRealtime() 和 System.currentTimeMillis() 来“估计”设备的正常运行时间。这是我的代码。
我认为这适用于毫秒时间错误是可以的应用程序。请留下你的想法。
I know that it's a very old question, but, I'm also struggling for converting
SensorEvent.timestamp
to a human readable time. So I'm writing here what I've understood so far and how I'm converting it in order to get better solutions from you guys. Any comments will be welcomed.As I understood,
SensorEvent.timestamp
is an elapsed time since the device's boot-up. So I have to know the uptime of the device. So if there is an API returning device's boot-up, it will be very easy, but, I haven't found it.So I'm using
SystemClock.elapsedRealtime()
andSystem.currentTimeMillis()
to 'estimate' a device's uptime. This is my code.I think this works for Apps that a millisecond time error is okey. Please, leave your ideas.