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



我的问题是,当扫描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'

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

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

你可以用intent integrator传递格式来扫描。例如:

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

相关内容

  • 没有找到相关文章

最新更新