如何扫描代码为39条形码格式的条形码

时间:2016-11-21 11:01:26

标签: android barcode zxing

我正在尝试使用zxing库扫描条形码,它的工作正常但我的条形码扫描格式:CODE_128,而不是我想要CODE_39,我的代码如下所示。

string key = uniqueStringKey;
var dict = new Dictionary<string, DateTime>();
dict.Add(key, DateTime.Now);

我在gradle中使用这些库

IntentIntegrator scanIntegrator = new IntentIntegrator(this); 
scanIntegrator.setDesiredBarcodeFormats(IntentIntegrator.ONE_D_CODE_TYPES.);
scanIntegrator.initiateScan();

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
        if (scanningResult != null) {
            Log.d("scanningResult:::::", scanningResult + "");
            LOGD("scanningResult scanContent:::::", scanningResult.getContents() + "");
            LOGD("scanningResult scanFormat:::::", scanningResult.getFormatName() + "");
        }
    }

请大家帮忙解决这个问题!!!

1 个答案:

答案 0 :(得分:0)

之后添加以下行if(scanningResult!= null){

 if(scanningResult.getFormatName().compareTo(BarcodeFormat.CODE_39.toString())== 0)
 {
 //method you want to invoke when the barcode is of type code39
 }

在ONE_D_CODE_TYPES之后有一个点,删除它。