QR Reader barcode.read

Discussions about creating CAPI applications to run on Android devices
Forum rules
New release: CSPro 8.0
Post Reply
jalsola
Posts: 6
Joined: February 3rd, 2021, 4:56 pm
Location: Panamá

QR Reader barcode.read

Post by jalsola »

Hello fellows, I have a big question!
I have been using the QR reader option on my A22 cell phone without any difficulty since April. The code I use is this:

Code: Select all

QR = barcode.read("Escanear el código QR"); 
The process is simply to get to a question, within my created questionnaire, and when I request the QR it appears like this:
Image
Image

As you can see, CsPro opens the camera for one to look for the QR to detect it. However, about 1 month ago CsPro does not identify the QR. What it does identify on the card is only the barcode but that information is not required.

You may think "maybe the QR is not valid, maybe the image is too small" or something like that, however, if I use the phone camera it does identify the same QR and displays the information.

Image

I can't show you a screenshot of the CsPro when it was working because it was not necessary at that time to save any screenshots, the only thing I could notice is that previously the CsPro when opening the camera did show the small QR identification box and currently it does not show it. I think it could be that CsPro was specifically opening the Qr Scanner on the cell phone because at that time the camera was blocked by a MDM (Mobile Device Management). Now the camera is enabled and does not identify it.
Image

If you have any solution or proposal please let me know and thank you.
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: QR Reader barcode.read

Post by Gregory Martin »

The problem, when I looked at your barcode before, was that it was encoded in ISO-8859-1 text, whereas most barcodes are encoded using UTF-8. CSEntry uses barcode reading code provided by Google as part of the Android system, and as you can see here, people have been complaining about its lack of support for ISO-8859-1 for over a year:

https://github.com/googlesamples/mlkit/issues/218

My guess is that your camera has special processing to handle ISO-8859-1, because my Google Pixel 5a (for the U.S. market) phone reads your barcode and indicates "Unknown encoding." In fact, I'm not even sure that your camera is reading the barcode correctly, because what displays as "PANAM" should actually be "PANAMÁ."

We will look into ways that we can support ISO-8859-1, but I'm not sure how quickly that will happen. If you are unable to encode your barcodes using UTF-8, your best option at the moment is to write a small Android application that reads barcodes, and use the SystemApp object to transfer this barcode to CSEntry.
jalsola
Posts: 6
Joined: February 3rd, 2021, 4:56 pm
Location: Panamá

Re: QR Reader barcode.read

Post by jalsola »

Thank you very much Gregory for the information and the prompt reply. I took your recommendation to create the small app that reads the QR and returns it with SystemApp.
Here I attach the small solution of the app on Android.

Code: Select all

        ActivityResultLauncher<ScanOptions> barcodeLauncher
                = registerForActivityResult(new ScanContract(), result -> {
            if (result.getContents() == null) {
                Toast.makeText(MainActivity.this, "Error", Toast.LENGTH_LONG).show();
            } else {
                Intent resulIntent = new Intent();
                resulIntent.putExtra("QRResult", result.getContents());
                setResult(Activity.RESULT_OK, resulIntent);
                Toast.makeText(MainActivity.this, result.getContents(),
                        Toast.LENGTH_LONG).show();
                finish();
            }
        });
        barcodeLauncher.launch(new ScanOptions());
Post Reply