【问题标题】:Zxing NotFoundException with Barcode 128CZxing NotFoundException with Barcode 128C
【发布时间】:2016-02-04 21:18:32
【问题描述】:

我尝试使用 Zxing 来解码 128C(代码集 C)条码。当我阅读其他类型(如 QR_CODE、UPC_A)时,我取得了成功。

这些是我试图读取的条形码:

Zxing 可以读取 128C 条码(不是纯 CODE 128)吗?

【问题讨论】:

    标签: java barcode zxing barcode-scanner code128


    【解决方案1】:

    简短的回答,是的,应该可能的。由于 128C 只是 128 的子集。可以扫描代码,可能需要几秒钟。并让 XZing 在应用中运行。

    您发现支持128,现在您必须进行翻译。 128C 采用与 128 相同的输入,只是输出数字。因此,您可以根据返回的数据进行翻译,并将其转换为 128C。检查第二个链接以了解其翻译方式。

    https://github.com/zxing/zxing/blob/master/README.md

    https://en.wikipedia.org/wiki/Code_128

    从 XZing github 获取所需的类,将它们放在项目的 java 部分的包中。我只用了2个:

    • IntentIntegrator
    • 意图结果

    这是在我的代码中启动的方式:

    /**
    * Method called to intiate the scan (it's linked to a button)
    */
    public void doScan(View view) {
        IntentIntegrator scanIntegrator = new IntentIntegrator(this);
        scanIntegrator.initiateScan();
    }
    
    // when you click the Scan Bar Code button
    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
        IntentResult scanningResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, intent);
    
        if (scanningResult != null) { // we have a result
    
    
               String scanContent = scanningResult.getContents(); // set the content of the scan.
               String scanFormat = scanningResult.getFormatName(); // set the type of scan.
    
               // You will want to put this data somewhere else, globals, etc.
    
            } else {
                toast("No scan data received!"); // call to make a toast
            }
        }
    

    【讨论】:

    • 我尝试使用 Zxing,但收到 NotFoundException。我相信这是 ZXing 算法中的东西。你能在你的应用程序中读取这些条形码吗?
    • 此处生成的代码有效:(已测试 128 和 128C)example.barcodephp.com/html/BCGcode128.php
    • 您的应用在启动时会崩溃吗?我的需要安装在应用程序上的条形码扫描仪来扫描。 / 我会发布我的做法。
    • 刚试过你提供的条形码,我可以扫描它们。所以这行得通。一些示例代码的时间。祝你好运!
    • 很高兴为您提供帮助!玩得开心!
    猜你喜欢
    • 2017-09-13
    • 2015-12-07
    • 1970-01-01
    • 2011-11-11
    • 2016-11-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多