在 Android 上获取运动传感器的真实时间戳

Get true timestamps of motion sensors on Android

众所周知,运动传感器的读数缓存在队列中,因此在实际采样数据和从队列中弹出数据之间可能会有一定的时间间隔。 SensorEvent中的timestamp成员是数据采样的时间吗?根据 SensorEvent 中的文档,可能不是。有没有办法测量数据采样的 "true" 时间戳?谢谢。

SensorEvent.timestamp是时间at which the event happened, or in other words, the time at which the data is generated。这是可用的最准确的时间戳值,您应该将此值用作计算中数据采样时间的 "true" 时间戳。