2016-01-04 99 views
0

我正在尝试使用ZXing library来开发谷歌眼镜条码扫描器(不要判断)。ZXing只识别QR码

扫描QR码完全正常,但我无法扫描任何1D条形码。

这是我的代码:

Intent intent = new Intent(this, CaptureActivity.class); 
//intent.putExtra("SCAN_MODE", "PRODUCT_MODE"); //doesn't work with or without this line 
startActivityForResult(intent, SCAN_REQUEST); 

下面是一个例子(EAN-8):
enter image description here

扫描这从Play商店中的扫描仪的工作原理我的手机上,而不是用我的在玻璃上的应用程序。

回答

0

我在 DecodeRunnable.java找到了解决我的问题的解决方法。
通过将BarcodeFormat.EAN_8添加到下面的代码中的列表中,我能够扫描条形码。

DecodeHandler() { 
    hints = new EnumMap<>(DecodeHintType.class); 
    hints.put(DecodeHintType.POSSIBLE_FORMATS, 
     Arrays.asList(BarcodeFormat.AZTEC, BarcodeFormat.QR_CODE, BarcodeFormat.DATA_MATRIX)); 
} 

您很高兴发布您的答案,因为我相信有更好的方法来解决这个问题。