0

光センサーの割り込みリスナーを登録しました。リスナーは、光レベル (ルクス) が変更されていなくても、常にイベントを取得します。

   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();
        }
    }
4

1 に答える 1