ZXing仅识别QR码 [英] ZXing only recognizes QR-Code
问题描述
我正在尝试使用
使用PlayStore中的扫描仪进行扫描可以在我的手机上使用,但不能在玻璃上使用我的应用程序.
我在 DecodeRunnable.java 中找到了解决我的问题的方法.
通过添加 BarcodeFormat.EAN_8
到下面代码中的列表中,我能够扫描条形码.
DecodeHandler(){提示=新的EnumMap<>(DecodeHintType.class);hints.put(DecodeHintType.POSSIBLE_FORMATS,Arrays.asList(BarcodeFormat.AZTEC,BarcodeFormat.QR_CODE,BarcodeFormat.DATA_MATRIX));}
很高兴发布您的答案,因为我相信有更好的方法来解决这个问题.
I am trying to develop a barcode scanner for google glass (don't judge) using the ZXing library.
Scanning QR-Codes works perfectly fine, but I can't scan any 1D-barcodes.
This is my code:
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);
Here is an example (EAN-8):
Scanning this with a scanner from the PlayStore works on my phone, but not using my app on the glass.
I found a workaround for my problem in the DecodeRunnable.java.
By adding BarcodeFormat.EAN_8
to the list in the code below I was able to scan the barcode.
DecodeHandler() {
hints = new EnumMap<>(DecodeHintType.class);
hints.put(DecodeHintType.POSSIBLE_FORMATS,
Arrays.asList(BarcodeFormat.AZTEC, BarcodeFormat.QR_CODE, BarcodeFormat.DATA_MATRIX));
}
You are wellcome to post your answers, because I believe there is a better way to solve this.
这篇关于ZXing仅识别QR码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!