如何触发在zxing体模式扫描 [英] How to trigger bulk mode scan in zxing

查看:150
本文介绍了如何触发在zxing体模式扫描的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看了有一键启用zxing批量模式下扫描。我想知道如何启用此键在Android应用程序?

I read there is a key to enable bulk mode scan in zxing. May I know how do i enable this key in an android application?

我目前使用这种codeS扫描单独一间酒吧code:

I am currently using such codes to scan a barcode individually:

Intent intent = new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_FORMATS", "PRODUCT_MODE,CODE_39,CODE_93,CODE_128,DATA_MATRIX,ITF");

startActivityForResult(intent, 0); // start the scan

谢谢!

推荐答案

还有就是大头模式无内zxing概念,我不认为。

There is no concept of "bulk mode" within zxing I don't think.

您当然可以实现您正在寻找的,虽然与zxing自己的应用程序中的行为。使用code,你已经在你的问题踢扫描的首次。加入这项声明你的类:

You can certainly implement the behavior that you are looking for though with zxing inside your own application. Use the code that you already have in your question to kick of Scanning for the first time. Add this declaration to your class:

ArrayList<String> results;

然后把里面的onCreate的 的你开始扫描前将它添加到初始化:

Then add this inside onCreate before you start scanning to initialize it:

results = new ArrayList<String>();

在你的onActivityResult(),您可以将当前结果添加到您的ArrayList,然后开始下一次扫描。

Inside your onActivityResult() you can add the current result to your ArrayList and then start the next scan.

/*Here is where we come back after the Barcode Scanner is done*/
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
    if (requestCode == 0) {
        if (resultCode == RESULT_OK) {
            // contents contains whatever the code was
            String contents = intent.getStringExtra("SCAN_RESULT");

            // Format contains the type of code i.e. UPC, EAN, QRCode etc...
            String format = intent.getStringExtra("SCAN_RESULT_FORMAT");

            // Handle successful scan. In this example add contents to ArrayList
            results.add(contents);

            Intent intent = new Intent("com.google.zxing.client.android.SCAN");
            intent.putExtra("SCAN_FORMATS", "PRODUCT_MODE,CODE_39,CODE_93,CODE_128,DATA_MATRIX,ITF");
            startActivityForResult(intent, 0); // start the next scan
        } else if (resultCode == RESULT_CANCELED) {
            // User hass pressed 'back' instead of scanning. They are done.
            saveToCSV(results);
            //do whatever else you want.
        }
    }
}

保存他们到一个CSV文件超出了这一具体问题的范围,但如果你看看周围,你可以找到如何做到这一点的例子。考虑它留空作为一个练习供您学习。

Saving them to a CSV file is beyond the scope of this specific question, but If you look around you can find examples of how to do it. Consider it left blank as an exercise for you to learn from.

这篇关于如何触发在zxing体模式扫描的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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