我为光传感器注册了中断监听器。即使光照水平(勒克斯)没有改变,监听器也会一直获取事件。
if (DeviceInfoHelper.isSensorSupported(context, mHostAppPackageName, SensorTypeValue.LIGHT)) {
lightSensor = sensorManager.getSensor(SensorTypeValue.LIGHT);
try {
if (lightSensor != null) {
lightSensor.registerInterruptListener(this);
Log.d(LOG_TAG, "register LightSensor ");
} else {
Log.w(LOG_TAG, "registerLightSensor: ERROR");
}
} catch (AccessorySensorException e) {
e.printStackTrace();
}
}