Home » Android » qr code – Android: Why does the second setText() not work?-Exceptionshub

qr code – Android: Why does the second setText() not work?-Exceptionshub

Posted by: admin February 26, 2020 Leave a comment

Questions:

When I scan QRCODE, my txtresult and txtqty should be updated, but only the txtresult was updated during the actual execution, soonly the first setText was executed.

barcodeDetector.setProcessor(new Detector.Processor<Barcode>() {

    @Override
    public void release() {
    }

    @Override
    public void receiveDetections(Detector.Detections<Barcode> detections) {

        final SparseArray<Barcode> qrCodes = detections.getDetectedItems();
        if (qrCodes.size() != 0) {
            code = qrCodes.valueAt(0).displayValue;
            qty = code.substring(code.indexOf("+") + 1);
            no = code.substring(0, code.indexOf("+"));
            txtresult.setText("no");
            txtqty.setText("qty");
        }
    }
});

Here is an example QR code:

QRCODE: CC515-2002000003+1700

How to&Answers: