I question myself what the timestamp in SensorEvent.timestamp means. Numbers like 3548712982000 occur. It is not plausible for anything: nanoseconds/milliseconds since 1970 etc. Is this maybe some overflow error? It seems as it is different on different devices at the same time!!!
Asked
Active
Viewed 1.1k times
1 Answers
24
Just a few seconds after this question on SO I found the answer:
See comment #18 of this issue where it's said that these are nanoseconds since boot (SystemClock.elapsedRealtimeNanos()
).
The android documentation definitively needs an update. The doc issue has been recently reported again, feel free to star it.
-
2This isn't wholly accurate unfortunately, as sensor events can sometimes get backlogged and be received 2 or 3 seconds after its initial creation time. This would mess up the arithmetic. Perhaps there's a way to find the time at which the system booted: i.e. the relative epoch. At the very least, it could be calculated by the current time minus `SystemClock.elapsedRealtimeNanos()` – Chris Watts Aug 20 '18 at 11:32