Other [B4X] [B4XPages] Barcode Reader - Formats

LucaMs

Expert
Licensed User
Longtime User
I could be wrong but I think you could change part of Sub CreateDetector like this:
B4X:
    #IF B4A
        builder.RunMethod("setBarcodeFormats", Array(0)) ' ALL_FORMATS constant, value 0
    #ELSE
        builder.RunMethod("setBarcodeFormats", Array(format))
    #End If
I think probably that way all formats for Android would be automatically supported, without having to add all the constants, even any new ones.
 

LucaMs

Expert
Licensed User
Longtime User
In real apps you usually don't want to detect all formats. The detector will work better if you set it to the specific formats that you are looking for.
Maybe so, but you're currently passing it a list of formats, it seems to me, so you might as well pass zero.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Maybe so, but you're currently passing it a list of formats, it seems to me, so you might as well pass zero.
Thinking about it, even though I haven't had a coffee yet šŸ˜ , that's an example. At the very least there might be a spinner filled with formats.
This makes me think of a question... which as a good member of B4X.com I don't post here.

P.S. Indeed, I have to look first, perhaps the example project already does what I was thinking.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
which as a good member of B4X.com I don't post here.
Well, I won't open a new thread because I don't need the answer, it was just a curiosity.

I would have liked to see if I could get the format, as well as the value.

Oddly that Maches variable which indicates the size of that sparse array returns 1 but if you log the "toString" method the values are more (but they don't contain the name of the format).

I thought about asking for the list of keys but... ok, it doesn't matter, it was just curiosity.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I would have liked to see if I could get the format, as well as the value.
Solved :):

B4X:
    mapFormats.Initialize
    mapFormats.Put(4096, "AZTEC")
    mapFormats.Put(1, "CODE_128")
    mapFormats.Put(2, "CODE_39")
    mapFormats.Put(4, "CODE_93")
    mapFormats.Put(8, "CODABAR")
    mapFormats.Put(16, "DATA_MATRIX")
    mapFormats.Put(32, "EAN_13")
    mapFormats.Put(64, "EAN_8")
    mapFormats.Put(128, "ITF")
    mapFormats.Put(2048, "PDF417")
    mapFormats.Put(256, "QR_CODE")
    mapFormats.Put(512, "UPC_A")
    mapFormats.Put(1024, "UPC_E")
B4X:
Dim FormatField As Object = barcode.GetField("format")
If FormatField <> Null Then
    Log(FormatField & "  " & mapFormats.Get(FormatField))
Else
    Log("format field is null")
End If
 
Upvote 0
Top