ZXing仅识别QR码 [英] ZXing only recognizes QR-Code

查看:89
本文介绍了ZXing仅识别QR码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用

使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆