Renz Manacmol
Renz Manacmol

Reputation: 939

Zxing Embedded Barcode Reader using (BarcodeView)

My question is when scanning a pdf417 barcode format sometimes it returns a UPC_E format base on the scan result?

here is a snippet of my code

 private BarcodeView barcodeView;

    private BarcodeCallback callback = new BarcodeCallback() {
            @Override
            public void barcodeResult(BarcodeResult result) {
                if (result.getText() != null) {          
    Toast.makeText(getActivity(), result.getText(), Toast.LENGTH_LONG).show();
                }
            }
            @Override
            public void possibleResultPoints(List<ResultPoint> resultPoints) {
            }
        };

here is the library

compile 'com.journeyapps:zxing-android-embedded:3.3.0'

Upvotes: 2

Views: 1158

Answers (2)

Renz Manacmol
Renz Manacmol

Reputation: 939

This solved the problem. long time ago :)

private BarcodeCallback callback = new BarcodeCallback() {
            @Override
            public void barcodeResult(BarcodeResult result) {
                if (result.getText() != null) {
                    String barcodeResult = result.getText();
                    String barcodeFormat = result.getBarcodeFormat().toString();
                    if (barcodeFormat.equals("PDF_417")) {
                        try {
                            String barcodeEncodedResult = new ConvertUtil().encodeIntoBase64(barcodeResult);
                            processEncodedResult(barcodeEncodedResult);
                        } catch (UnsupportedEncodingException e) {
                            e.printStackTrace();
                        }
                    } else {
                        Toast.makeText(getActivity(), "Unable to read as PDF_417 barcode format", Toast.LENGTH_LONG).show();
                    }
                }
            }

Upvotes: 1

Randyka Yudhistira
Randyka Yudhistira

Reputation: 3652

you can pass the format to scan with intent integrator. Something like :

IntentIntegrator integrator = new IntentIntegrator(this); 
integrator.setDesiredBarcodeFormats(IntentIntegrator.PDF_147);
intent = integrator.createScanIntent();
barcodeView.initializeFromIntent(intent);

Upvotes: 0

Related Questions