I just realised that on android the timestamps you get from a GPS Location update are in ms since epoch whereas the timestamps of SensorEvent updates(e.g. of the Accelerometer) are in ns since startup.
I would like to convert the GPS timestamps to the format of the SensorEvent timestamps, does anyone know a good method to do this?
I tried the following: I measured once the time of system startup since epoch:
startupTime = System.currentTimeMillis() - SystemClock.uptimeMillis();
For each gps location update I subtract the startup time:
timestamp = loc.getTime() - startupTime;
But those converted timestamps do still not conform to SensorEvent timestamps, there is still a difference of a couple of seconds...
Do not use SystemClock.uptimeMillis(), since it measures the time since boot without the time where the device was in sleep mode. Instead use SystemClock.elapsedRealtime().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With