public void setTorch(boolean on) {
        if (camera != null) {
            try {
                boolean isOn = isTorchOn();
                if (on != isOn) {
                    if (autoFocusManager != null) {
                        autoFocusManager.stop();
                    }

                    Camera.Parameters parameters = camera.getParameters();
                    CameraConfigurationUtils.setTorch(parameters, on);
                    if (settings.isExposureEnabled()) {
                        CameraConfigurationUtils.setBestExposure(parameters, on);
                    }
                    camera.setParameters(parameters);

                    if (autoFocusManager != null) {
                        autoFocusManager.start();
                    }
                }
            } catch(RuntimeException e) {
                // Camera error. Could happen if the camera is being closed.
                Log.e(TAG, "Failed to set torch", e);
            }
        }
    }
A single preview frame will be returned to the supplied callback.

The thread on which this called is undefined, so a Handler should be used to post the result
to the correct thread.

@param callback The callback to receive the preview.
zxing-android-embedded/src/com/journeyapps/barcodescanner/camera/CameraManager.java