I would like to read PDF417 bar codes

175 views Asked by At

I need to read a PDF417 barcode.

The following code, however, causes my app to open a dialog which asks to Install Barcode Scanner" when running on my Android phone.

The dialog gives me options to install a "BARCODE SCANNER" and to install "BARCODE SCANNER + SIMPLE".

The "BARCODE SCANNER" option installs an app on the phone (via the PlayStore). The "BARCODE SCANNER + SIMPLE" option takes me to a page in the PlayStore that says "Something went wrong".

After installing the app on the first option, clicking the button in my app displays the same dialog asking to install the application.


    private void scanDisk() {
        CodeScanner scanner = CodeScanner.getInstance();

        if (scanner == null) {
            CodenameOneUtils.toastMessage("Scanner is null");
            return;
        }

        scanner.scanQRCode(new ScanResult() {
            @Override
            public void scanCompleted(String s, String s1, byte[] bytes) {
                CodenameOneUtils.showDialog(s + "/n" + s1);
            }

            @Override
            public void scanCanceled() {
                // nothing - do we care?
            }

            @Override
            public void scanError(int i, String s) {
                // we should really show a message...
                CodenameOneUtils.toastMessage("Scan failed: " + s);
            }
        });
    }
1

There are 1 answers

9
Shai Almog On

Try adding Display.getInstance().putProperty("scanAllCodeTypes", "true") to the init(Object) callback in your main class. This should force scanning for any type of QR/bar code as seen from this code.

If this doesn't work or isn't efficient we might need to do something more aggressive.