我问自己,SensorEvent.timestamp中的时间戳是什么意思.出现了像3548712982000这样的数字.这对任何事情都不合理:自1970年以来的纳秒/毫秒等.这可能是一些溢出错误吗?看起来它在同一时间在不同的设备上是不同的!
我正在对加速度计传感器进行采样,并使用库(4.0.1)实时呈现图表Graph View。
该应用程序运行良好,只是图表错误:
正如您在图片中看到的,Z 轴(洋红色)的值为 ~9.8,但在图表中显示为 ~15,Y 轴(绿色)的值为 0.2,但在图表中我们在零和相同的想法下与 X 轴。
这是我的代码:
SensorManager sensorManager;
TextView tvX, tvY, tvZ;
GraphView graph;
LineGraphSeries<DataPoint> seriesX, seriesY, seriesZ;
long startTime;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_runtime_graph);
tvX = (TextView) findViewById(R.id.tvAcc_X); // color : blue
tvY = (TextView) findViewById(R.id.tvAcc_Y); // color : green
tvZ = (TextView) findViewById(R.id.tvAcc_Z); // color : magenta
graph = (GraphView) findViewById(R.id.graph);
seriesX = new LineGraphSeries<>();
seriesY = new LineGraphSeries<>();
seriesZ = new LineGraphSeries<>();
seriesX.setColor(Color.BLUE);
seriesY.setColor(Color.GREEN);
seriesZ.setColor(Color.MAGENTA);
graph.addSeries(seriesX); …Run Code Online (Sandbox Code Playgroud) 我已经从Android可穿戴设备中提取了加速度计数据。在查看数据时,我意识到时间戳记无法在UNIX上覆盖。经过研究,我发现时间戳实际上是正常运行时间的纳秒。我的问题与Accelerometer SensorEvent时间戳相同。但是由于我不了解Java,我不知道如何使用提供的解决方案将其转换。有什么python方法可以将正常运行时间中的纳秒转换为可读的日期时间格式?时间戳的示例为“ 45900482044637”。