Android Sensor Timestamp reference time

Pablo A. Martínez picture Pablo A. Martínez · Oct 14, 2011 · Viewed 8.1k times · Source

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

Answer

manu3d picture manu3d · Oct 15, 2011

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.