B4A Library ABZxing Barcode reader

This is a library to read barcodes. It uses the Zxing app to do the scanning. If the Zxing app is not installed, the user is redirected to the Android market to download the app.

Functions:

ABGetBarcode (eventName as String, mode as String)

Starts the barcode scanner. The barcode is returned in the BarcodeFound event or the Canceled event

Params:
eventName (String): name of the ABBarcode object (lowercase!)
mode (String):
"" for everything
"QR_CODE_TYPES" for QR codes
"PRODUCT_CODE_TYPES" for UPC_A,UPC_E,EAN_8,EAN_13
"ONE_D_CODE_TYPES" for UPC_A,UPC_E,EAN_8,EAN_13,CODE_39,CODE_93,CODE_128

Example:

B4X:
Sub Button1_Click
    myABBarcode.ABBarcodeGet("myABBarcode", "QR_CODE_TYPES")
End Sub

Sub myABBarcode_BarcodeFound(barCode as String, formatName as String)
    msgbox(barCode, "")
End Sub

Sub myABBarcode_Canceled
    msgbox("Canceled","")
End Sub
 

Attachments

  • ABZxing.zip
    6 KB · Views: 6,244
  • ABBarcodeTest.zip
    5.7 KB · Views: 5,277
Last edited:

JDS

Active Member
Licensed User
Longtime User
I'm trying to use this library and it work great when the barcode represents plain numbers.
But now we have a barcode (Code_128) which contains characters like "rik1WEUBMW+vfLtZbN8t+w==" (without the quotes). This barcode is very hard to scan (takes about 3 minutes before it returns anything, if it returns something at all) and when the scanner returns a value it isn't the right value.
I've tried QuickMark and Google Goggles but with those I didn't get a hit at all.

Any thoughts?
 

joneden

Active Member
Licensed User
Longtime User
Hi @alwaysbusy,

I'm trying to force the barcode app to stop after 10 seconds (to prevent it remaining open if unused). I've tried killing the process, returning to the main activity etc but nothing works. How would I force a cancel event from my app to ABZXing?

Thanks for any help

Regards,

Jon
 

JTmartins

Active Member
Licensed User
Longtime User
Same here

Hi,

I also would like to know how to cancel the scan after a certain amount of time and return to our activity in the place we left

If anyone could help, would be appreciated.

Thanks

José
 

joneden

Active Member
Licensed User
Longtime User
I'm still having the issue with closing the object. In the event that nobody does a scan I can get control retured to my app but behind the scenes the scanner window is still running.

Each time the user lets the time out happen another instance of the scan window seems to be orphaned behind my app. When my app closes I have to manually back out of each of the windows.

I'm trying to use an OperatingSystem object to get a list of processes and then kill the ABZXing process but it doesn't appear in the list.

Any advice?

Many thanks

Jon
 

joneden

Active Member
Licensed User
Longtime User
Hi Alain,

Following on from my above comment I'm guessing that the call cannot be killed as the ABZXing is an extension of the activity that calls it.

To that end is there any way that the ABZXing could have a timer added to it to get rid of the intent if no response in a certain number of seconds?

Regards,

Jon
 

GaNdAlF89

Active Member
Licensed User
Longtime User
I have a problem of recognition of a barcode, with the barcode scanner downloaded with this library. The problem is that the barcode is not focused, it is blurry. I have Samsung Galaxy Tab 2 with Android 4.0.3. How can I resolve?
 

MarcSchambers

New Member
Licensed User
Longtime User
Single Code Type Only

Params:
eventName (String): name of the ABBarcode object (lowercase!)
mode (String):
"" for everything
"QR_CODE_TYPES" for QR codes
"PRODUCT_CODE_TYPES" for UPC_A,UPC_E,EAN_8,EAN_13
"ONE_D_CODE_TYPES" for UPC_A,UPC_E,EAN_8,EAN_13,CODE_39,CODE_93,CODE_128
]

Is there a way, or can a way be made, to only select 1 type of code?

I want to lock the scanner down to just CODE_39, but it appears currently with this library I can only lock it down to 1D code types in general.

Thanks!
 

NJDude

Expert
Licensed User
Longtime User
You will have to ask if the scanned barcode is the format you need, like this:
B4X:
Sub myABBarcode_BarcodeFound(BarCode As String, FormatName As String)

    If FormatName = "CODE_39" Then

        MsgBox(Barcode, "")

    End If

End Sub

Also, the code above will work using the ZXing app, if you use Google Search the FormatName will be blank.
 

GaNdAlF89

Active Member
Licensed User
Longtime User
I have a problem! I want that my app can read a barcode only in 10 seconds, after 10 seconds I use kiosk service to return to my app. Ther problem is that barcode scanner app remain in background; I want to close it.
I think that with the OSlibrary, I can obtain the pid of barcode scanner process, and then kill it with killProcess function (in OSLibrary), but I need its name. Where can I find this name?
 

GaNdAlF89

Active Member
Licensed User
Longtime User
The problem is that, when I close the current activity with Activity.Finish, I see the barcode scanner app, instead of the main activity of my app, as I expect..
 

GaNdAlF89

Active Member
Licensed User
Longtime User
I tried this solution, but it doesn't work! The problem is not solved...What can I do?
 
Last edited:

ivan.tellez

Active Member
Licensed User
Longtime User
Great Lib

This is really a great Lib.

Just as info, this works also with QR Droid and Google's Goggles.

I have a suggestion, please allow localization. Maybe a property ro replace the message in case ZXing its not installed.

And a Question. Is there a way to read a QR code saved as a picture in the gallery?

Thanks
 

juanomoran

Member
Licensed User
Longtime User
Thanks for this great library. I have been using it without trouble... until yesterday!

A brief description of the previous working solution:
a) Activity.loadlayout("a layout containing some buttons (i.e. btnScan) and labels")
b) Event listener "btnScan_click" that calls the zx object with zx.beginscan("myzx")
c) Sub myzx where I grab the scanned code and pass it to a global variable and show it in one of the layouts labels.


The problem arises when I try to call this library from a layout inside a sliding panel (AHPager). It just doesn't work. I debbug the application. It properly calls the beginscan and follows into the myzx sub. But it never shows the scanning screen and the result is "0". The same also happens if I place a button outside the pager, but within the same activity. Is there any known compatibility issue between ahpager and zxing libraries?

I'm at work now, so I don't have access to my code to show the results log.

Of course I can try a different approach, like not using sliding panels. But I really like the proffesional look and feel they provide.

Thanks in advance
 

juanomoran

Member
Licensed User
Longtime User
Ok, now I tried to use te Zxing library with the tabHost views and the same problem apperas. The actual results log is: "Got other result code:0". So, I think that it is a problem with the activity holding different tabs.

I guess that I can "solve" it by calling another activity when pressing the scan button and returning the values to the original activity.

I will try this.
 

zsezo

Member
Licensed User
Longtime User
Hello, I just wanna to ask somebody the Cancelled event when will be fired? I created an app, with continuous barcode reading. I'd like to terminate with the Cancelled event, but the cancelled event never fired for me. What can I miss or how can I catch the back button.
ABZxing (version 1.00)

Tested on: Galaxy Y (2.2), Galaxy S3 (4.2.2), Galaxy S4 (4.2.2)

o_O:mad::confused: Any idea? o_O:mad::confused:

TIA!

UPDATE! Oh my bad! I wrote Cancelled instead of Canceled... :)
 
Last edited:
Top