问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/34589203/zxing-only-recognizes-qr-code