Search code examples
javaandroidqr-codezxing

Set Scanner to Read Only QR Code and Ignore other type of BarCodes


I am using this library to scan QR Codes. This library is very simple but I am having a hard time trying to figure out on making it to responds only to QR Codes.

It uses ZXing behind it.

CamView

    //MARK - scannerLiveView
    ZXDecoder decoder=new ZXDecoder();
    decoder.setScanAreaPercent(0.5);

    ScannerLiveView scannerLiveView = (ScannerLiveView) findViewById(R.id.scannerLiveView);
    scannerLiveView.setDecoder(decoder);

Here is how I did it. But the problem is that it responds to all kind of bar codes. I would like to have it responds on QR Codes only.

Any thoughts??


Solution

  • The problem is that ZXDecoder is hardcoded to scan all possible formats. https://github.com/LivotovLabs/CamView/blob/53e3112592980754628bab2b770ed16900b9c407/CAMView/src/main/java/eu/livotov/labs/android/camview/scanner/decoder/zxing/ZXDecoder.java. You could create a new class QRDecoder which should look pretty much the same as ZXDecoder but instead of creating MultiFormatReader it should create QRCodeReader