bar code scanner is too slow to read the code

Deadly 提交于 2019-12-01 11:21:36

问题


I have used codenameone codescanner library to read bar code. It uses third party scanner which if used separately works fine and is quick to read the bar code. But using codenameone app, the same scanner is too slow(most of the time unable to scan). I have tested it in samsung devices and few other devices. The outcome is not so good. How can I enhance the scanner?

code:

 CodeScanner.getInstance().scanBarCode(new ScanResult() {

    public void scanCompleted(String contents, String formatName, byte[] rawBytes) {
        //barCode.setText("Bar: " + contents);
        cnt.addComponent(new Label(contents));
        cnt.revalidate();
    }

    public void scanCanceled() {
        System.out.println("cancelled");
    }

    public void scanError(int errorCode, String message) {
        System.out.println("err " + message);
    }
});   

One more thing, some time it reads the bar code but gives different code rather than those written below the code. for eg I was scanning IMEI no of mobile device, it has more than 15-20 numbers, but the scanner gives the 5-6 digit numbers other than those IMEI numbers. What happened here?

you can see the problem in the video... https://youtu.be/xCtx0ZlFH0U


回答1:


Try setting the explicit code type you are trying to read e.g.:

Display.getInstance().setProperty("android.scanTypes", "UPC_E");

You can see the list of code types here.

Alternatively try the little monkey QR code library (it works with barcodes too) it's often better on Android.



来源:https://stackoverflow.com/questions/41886104/bar-code-scanner-is-too-slow-to-read-the-code

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!