Android Question Read QR Codes and store it in a variable - reg.

beelze69

Active Member
Licensed User
Longtime User
Hi !

I have a desktop application that generates a QRCode.

For example:

Suppose my application generates the string '1|Erel|Israel' as a QRCODE.

I take a print of this and stick it to some object.

[Here '|' is the field delimiter]. The values are for fields PERSON_ID,PERSON_NAME,COUNTRY

Now I want to develop a b4A application which will scan this printed QRCODE and store the string in a VARIABLE
so that I can extract the individual field data values and store in database/perform searches etc.

Please help.

Thanks.
 

TILogistic

Expert
Licensed User
Longtime User
Suppose my application generates the string '1|Erel|Israel' as a QRCODE.

1. Generate a json with the variables (JSONGenerator)
B4X:
    Dim JSONGenerator As JSONGenerator
    JSONGenerator.Initialize(CreateMap("PERSON_ID": "1", "PERSON_NAME": "Erel","COUNTRY": "Israel"))
    Dim Data As String = JSONGenerator.ToPrettyString(2)
{
"PERSON_ID": "1",
"PERSON_NAME": "Erel",
"COUNTRY": "Israel"
}
2. Generate a QR Image with the JSon
1608440548193.png

3. Scan the QR image and get the json string
<Text> = QR data
B4X:
Dim parser As JSONParser
parser.Initialize(<text>)
Dim root As Map = parser.NextObject
Dim PERSON_NAME As String = root.Get("PERSON_NAME")
Dim COUNTRY As String = root.Get("COUNTRY")
Dim PERSON_ID As String = root.Get("PERSON_ID")
Tools:
 
Last edited:
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
If you already have your application that generates the QR image, I recommend that you generate the QR image with data in Json format

QR reader.
B4X:
Dim parser As JSONParser
parser.Initialize(<text>)
Dim root As Map = parser.NextObject
Dim PERSON_NAME As String = root.Get("PERSON_NAME")
Dim COUNTRY As String = root.Get("COUNTRY")
Dim PERSON_ID As String = root.Get("PERSON_ID")
Other:
Search: https://www.b4x.com/android/forum/pages/results/?query=QR+reader.
 
Last edited:
Upvote 0
Top