如何使用Android在Service中读取加速度计数据

use*_*597 5 service android accelerometer

通常,在Android中,我们通过覆盖OnSensorChanged函数来读取"Activity"中的加速度计数据.

我很好奇我们如何在"服务"中做到这一点.

谢谢,文森特

bba*_*a42 7

实际上OnSensorChanged(SensorEvent event)是来自SensorEventListener接口的方法.

所以,如果你想在服务中做到这一点; 你创建了扩展Service和实现的新类SensorEventListener.