Dimitris Sioulas Dimitris Sioulas - 1 year ago 120
Android Question

Enable flashlight in QR CODE READER

I want to scan a qr code with flashlight enabled in android app. I am using this library https://github.com/dlazaro66/QRCodeReaderView. Is there any way to enable the flashlight when I have already opened my camera for scan?

Answer Source

You will have to modify QRCodeReaderView.java file from your library. Replace the "surfaceCreated" method with this one:

public void surfaceCreated(SurfaceHolder holder) {
    boolean useFlash = true;

    try {
        // Indicate camera, our View dimensions
    } catch (IOException e) {
        Log.w(TAG, "Can not openDriver: "+e.getMessage());

    try {
        mQRCodeReader = new QRCodeReader();
        if (useFlash){
            Parameters p = cam.getParameters();

    } catch (Exception e) {
        Log.e(TAG, "Exception: " + e.getMessage());
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download