注册传感器:使用SensorManager的registerListener(SensorEventListener listener, Sensor sensor, int rate)方法

SensorEventListener 有两个需要实现的方法:

1. onAccuracyChanged(Sensor sensor, int accuracy)   //传感器精度改变时自动调用

2. onSensorChanged(SensorEvent event)  //传感器改变时自动调用

event里面有一个values属性,返回一个float数组,保存的数值就是传感器返回的数值

A. 光传感器中,返回的values[0] 表示的就是光的强度 

相关文章:

  • 2021-12-05
  • 2022-12-23
  • 2021-06-15
  • 2022-12-23
  • 2021-10-21
  • 2021-07-30
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-17
  • 2022-02-03
  • 2021-07-30
  • 2021-09-23
  • 2022-12-23
  • 2021-08-27
相关资源
相似解决方案