将扫描仪设置为只读 QR 码并忽略其他类型的条码

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

我正在使用这个库来扫描二维码。这个库非常简单,但我很难弄清楚如何让它只响应二维码。

背后用的是ZXing

CamView

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

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

这是我的做法。但问题是它对所有类型的条形码都有反应。我想让它只响应二维码。

有什么想法吗??

问题是 ZXDecoder 被硬编码为扫描所有可能的格式。 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