Zxing嵌入式条码阅读器使用(BarcodeView)

时间:2016-08-29 01:41:55

标签: java android zxing barcode-scanner pdf417

我的问题是,当扫描pdf417条形码格式时,它有时会根据扫描结果返回UPC_E格式吗?

这是我的代码片段

 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) {
            }
        };

这是图书馆

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

2 个答案:

答案 0 :(得分:1)

这解决了问题。很久以前:)

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();
                    }
                }
            }

答案 1 :(得分:0)

您可以使用intent integrator传递格式进行扫描。类似的东西:

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