我在晴雨表服务中有这个功能:
public void StartHpsUpdates()
{
var x = (SensorDelay)125000000;
var d = 125000000;
sm.RegisterListener(this, _pressure, x, d);
}
应该每125秒读取一次传感器数据。
我也有事件处理程序
public void OnSensorChanged(SensorEvent e)
{
this.SensorChanged(this, new SensorChangedEventArgs(e));
var hps = e.Values[0];
Log.Debug(logTag, String.Format("Hps is {0}", hps));
}
将数据打印到控制台,以进行测试。但是,而不是每2分钟读一次数据,在控制台中我每30-40秒就会得到数百个读数,就像这样
11-15 11:09:09.501 D/LocationService(25609): Hps is 1002,648
11-15 11:09:09.511 D/LocationService(25609): Hps is 1002,653
11-15 11:09:09.531 D/LocationService(25609): Hps is 1002,66
11-15 11:09:09.541 D/LocationService(25609): Hps is 1002,667
11-15 11:09:09.551 D/LocationService(25609): Hps is 1002,67
11-15 11:09:09.551 D/LocationService(25609): Hps is 1002,676
11-15 11:09:09.561 D/LocationService(25609): Hps is 1002,677
11-15 11:09:09.571 D/LocationService(25609): Hps is 1002,674
我试图找到解决方案,但到目前为止没有运气,看起来没有人使用压力传感器。有人能指点我怎么做吗?