Zxing ITF酒吧code在自定义应用程序不扫描 [英] Zxing ITF barcode not scanning in custom app

查看:248
本文介绍了Zxing ITF酒吧code在自定义应用程序不扫描的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用zxing吧code里面我的应用程序之一,扫描棒codeS。我已经使用意图启动按钮上依次点击栏code扫描仪。

I am trying to use zxing barcode inside one of my app to scan barcodes. I have used intent to start the barcode scanner on a button cick.

Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
startActivityForResult(intent, 0);

我发现的是,大多数的酒吧code可以扫描正常,但当我尝试扫描我的应用程序内的ITF(5交错2)条code它不工作,但如果我只是用斑马线酒吧code扫描仪正常工作。

What I have found is that most barcode can scan fine but when I try to scan the ITF (Interleaved 2 of 5) barcode within my app it doesnt work but if I just use the zxing barcode scanner it works fine.

现在我一直在寻找了一段时间,并已阅读,我可以使用ALLOWED_LENGTH。我无法找到多的信息,如何在这个信息到扫描仪通过。我尝试以下,但它不是实拍任何区别。

Now I have been searching for a while and have read that I can use ALLOWED_LENGTH. I couldnt find much information as to how to pass in this information to the scanner. I tried the following but its not really making any difference.

**int[] item = new int []{6, 7, 8, 9, 10, 11, 12, 13};**
**intent.putExtra("ALLOWED_LENGTHS", item);**

我加了上面两行到我的code。是否有人可以让我知道什么是达致这正确的方法吧。

I added the two lines above to my code. Can someone please let me know what is the correct way to acheive this please.

在此先感谢

推荐答案

解决方案

intent.putExtra("SCAN_MODE", Intents.Scan.ONE_D_MODE);

请注意:你或许应该使用所提供的意图,而不是硬编码字符串额外

Note: You should probably use the provided intents, instead of hard-coding the extras string

说明

这已经无关允许长度。 ITF不是的PRODUCT_MODE格式

This has nothing to do with allowed lengths. ITF is not one of the PRODUCT_MODE formats

PRODUCT_FORMATS = EnumSet.of(BarcodeFormat.UPC_A,
                             BarcodeFormat.UPC_E,
                             BarcodeFormat.EAN_13,
                             BarcodeFormat.EAN_8,
                             BarcodeFormat.RSS_14,
                             BarcodeFormat.RSS_EXPANDED);

它包括在一维格式列表

It is included in the list of 1D formats

ONE_D_FORMATS = EnumSet.of(BarcodeFormat.CODE_39,
                           BarcodeFormat.CODE_93,
                           BarcodeFormat.CODE_128,
                           BarcodeFormat.ITF,
                           BarcodeFormat.CODABAR);
ONE_D_FORMATS.addAll(PRODUCT_FORMATS);

改变你的意图的额外将使ITF的支持,但可能有其他后果(如产品搜索功能)

changing your intent extra would enable ITF support, but might have other consequences (eg product search functionality)

这篇关于Zxing ITF酒吧code在自定义应用程序不扫描的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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