public void switchFlashlight(View view) {
        if (getString(R.string.turn_on_flashlight).equals(switchFlashlightButton.getText())) {
            barcodeScannerView.setTorchOn();
        } else {
            barcodeScannerView.setTorchOff();
        }
    }
Check if the device's camera has a Flashlight.
@return true if there is Flashlight, otherwise false.
sample/src/main/java/example/zxing/CustomScannerActivity.java