public void start() {
        if (cameraSettings.isAutoTorchEnabled()) {
            SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
            lightSensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
            if (lightSensor != null) {
                sensorManager.registerListener(this, lightSensor, SensorManager.SENSOR_DELAY_NORMAL);
            }
        }
    }
Detects ambient light and switches on the front light when very dark, and off again when sufficiently light.

@author Sean Owen
@author Nikolaus Huber
zxing-android-embedded/src/com/google/zxing/client/android/AmbientLightManager.java