Qr : Read and Create Qr/Bar Code offline

1.Introduction

Recently there were some topics(on Kodular Community) about generating qr code offline and storing on device and I got inspiration/idea to create Qr extension.
It can generate and read Qr Code and Bar Code completely offline.
Latest Version: 5.3
Released:2020-03-20T18:30:00Z
Last Updated: 2024-06-10T18:30:00Z

2.Blocks

image

image

Just 3 method and 2 event blocks

3.Documentation

A short documentation for the extension-

Creates BarCode and raises event 'BarCodeGenerated' with response and filepath
Note: File Path should be absolute like /storage/sdcard/qr.png

image

Decodes BarCode and raises event 'BarCodeDecoded' with result

image

Returns a list of supported Bar code formats which can be either decoded or encoded

4.Downloads

Aix can be found here:

Thank you :heart:

18 Likes

Thank you. However:

unlisted until corrected...

4 Likes

Hi! I've almost got this working I think. The block of code below prints a "file not found" error into the text box. Do you know what I'm missing?
qr1

use Do it to debug your blocks, see also tip 4 here https://puravidaapps.com/learn.php
see also Live Development, Testing, and Debugging Tools
Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

1 Like

Hi @ZonaKyle Welcome
Probably because file you want to decode does not exists.
Be sure to check if it exists or not before decoding.
Also you can find latest version here:

ChangeLog Version 4

Changes

  • Added logoPath parameter in GenerateBarCode method
  • Changed package name to com.sunny.qr from com.sunny.Qr
  • The extension does not ask for any permission and uses absolute file paths

Download Link: com.sunny.qr.aix (14.0 KB)

Note: Still you will have to additionally use a BarcodeScanner component

Credits: I am thankful to @Ayoub_Dev for the source of QrLogo extension.

1 Like

Testing this in companion, I get a list of formats:

["AZTEC", "CODABAR", "CODE_39", "CODE_93", 
"CODE_128", "DATA_MATRIX", "EAN_8", "EAN_13", 
"ITF", "MAXICODE", "PDF_417", "QR_CODE", 
"RSS_14", "RSS_EXPANDED", "UPC_A", "UPC_E", 
"UPC_EAN_EXTENSION"]

However, only QR_CODE and PDF_417 generate an image/code.

Is there are reason for this?

(tested on Android 10 and Android 11 devices)

That's a list of formats which can be either encoded or decoded (some formats support both).

CODE_39 should also work.

Unfortunately Code_39 does not work either

Maybe becuause of android version.

This .aia is created in Kodular and is not compatible with AI2.

Ahh, please don't use that URL.

1 Like

Here are the blocks:
Generate Bar Code
image
Decode Bar Code
image

I made a test app:
QR.aia (15.0 KB)

Problem 1 - Created PNG file is empty.
Problem 2 - When I use ImagePicker to get a QR code from my phone, I get an error: com.google.zxing.NotFoundException.
Problem 3 - App crashes on startup after compiling, with companion works fine.

Probably given logo does not exist.

Have you asked for WRITE_EXTERNAL_STORAGE permission?
Also I suggest you to not use ImagePicker.Selection block because it creates unnecessary temp files.You should use Activity Starter along with FileTools or TaifunFile extension.
See here how:

You have not put a barcode scanner component.

This should work fine:
Qr.aia (33.2 KB)

Yeah. I don't have a logo. I thought that made the logo :). What is a qr code logo?

Yes permission granted. ImagePicker returns the path to the created temporary file. The temporary file exists, so it should decode qr correctly. I work with ActivitiStarter later.

I did not know that a scanner is needed. I thought it was an independent extension

Sometimes we want to decorate qr code with watermarks.That is it.

From where have you downloaded bar/qr code?

No, it needs some deps which are only available in Barcode Scanner component.

1 Like

What is the maximum length of the text that you can encode in QRCODE? With short text, the extension generate and decodes well. When the text is a long, QR code is generated correctly, while when decoding there is a COM.GOGLE.ZXING.NOTFOUNDEXCEPTION error. I will add that the scanner correctly decodes the QR code.

QrScan800.aia (54.5 KB)

Text:
0000FA550602FF00000000550603FF00000000550607FF00000000550608FF000000000096550603FF4400000055060422200000005506087F41000000003C550602FF09000000550603FF4C000000003C550602FF0D000000550607FF040000005506087F61000000003C550602FF1D0000005506087F69000000003C550603FF4D0000005506042222000000550607FF0C000000003C550602FF5D000000550607FF8C000000003C550607FF9C000000003C550603FF6D000000003C550603FFEF000000003C5506087F6F000000003C550607FFDC000000003C550602FFFD000000550603FFFF000000003C550607FFFF0000005506087F7F000000FA550603FFBB00000055060422020000005506087F3E000000003C550602FFF4000000550603FFB3000000003C550602FFF0000000550607FFFB0000005506087F1E000000003C550602FFE00000005506087F16000000003C550603FFB20000005506042200000000550607FFF3000000003C550602FFA0000000550607FF73000000003C550607FF63000000003C550603FF92000000003C550603FF10000000003C5506087F10000000003C550607FF23000000003C550602FF00000000550603FF00000000003C5506080000000000550607FF0000000000965506020000000000550603000000000055060400000000005506070000000000010064

QR:

Another thing is whether I can save the logo in the APP resources? I tried to give the path to the logo "http://localhost/logo.png" but it does not work.

It means either:

  • dimensions are larger than expected
  • orientation has been changed
  • some pixels have been lost

Usually extensions don't use that path.So // will work for assets.