Scaning Bar Codes with Android

59 views
Skip to first unread message

David

unread,
Jun 2, 2015, 9:17:55 AM6/2/15
to codenameone...@googlegroups.com
Hi all,

I'm trying to implement bar code scanning functions for Android devices.
I have tried CodeScanner, LITTLEMONKEY QR & BARCODE SCANNER and Zxing (based on Zxing demo) APIs but none of them gave a good result (by the way, QR code scanning works very well with CodeScanner API). Most of the time the app couldn't even read the barcode and when it could it took a long time and the results were wrong. That doesn't happen with Zxing library based apps, like Barcode Scanner, they work very efficiently for barcode scanning in Android devices.

I suppose the only way to implement an efficient bar code scanning for CN1 is by using native coding and a well know library for Android like zxing.
Is that right or is there a better way to do it?

Thanks in advance,

David

Shai Almog

unread,
Jun 2, 2015, 10:14:24 AM6/2/15
to codenameone...@googlegroups.com, ramalh...@gmail.com, ramalh...@gmail.com
Hi,
the QR lib from littlemonkey works really well for barcodes and was actually meant to improve on that. Are you sure you used it correctly (used their API and added their build hints?).

ramalh...@gmail.com

unread,
Jun 4, 2015, 11:11:45 AM6/4/15
to codenameone...@googlegroups.com, ramalh...@gmail.com
Hi Shai,

Thanks for the quick reply.
I believe I have used in the correct way, since it works for QR Codes. I have followed the instructions and added build hints.

Please find in the link below a video and a Netbeans Project I have done as an example.



Regards,

David

Shai Almog

unread,
Jun 5, 2015, 1:27:33 AM6/5/15
to codenameone...@googlegroups.com, ramalh...@gmail.com, ramalh...@gmail.com
Hi,
what type of barcode is this?

David Ramalho

unread,
Jun 5, 2015, 11:01:28 AM6/5/15
to Shai Almog, codenameone...@googlegroups.com
Hi Shai,

This is a Code 128 barcode which I need to read in my app.
I tested other types and I found out both CodeScanner and LMonkey both work for EAN barcodes. Are these the only type supported?

Thanks,

David

nickk...@gmail.com

unread,
Jun 5, 2015, 6:56:09 PM6/5/15
to codenameone...@googlegroups.com, ramalh...@gmail.com, shai....@gmail.com
Hi,

The LittleMonkey library only supports EAN as it is, however its build on zbar which supports Code 128.

Get the source from github and edit native/android/org/littlemonkey/qrscanner/NativeScannerImpl.java

If you only want to scan Code 128 instead of EAN then change Symbol.EAN to Symbol.CODE128.  If you want it to recognize more types just put them in the int[] (line 27 on my version).

Clean and Build to get the .cn1lib (in the dist directory) and replace the current one in your project and refresh libs.

Cheers,
Nick

Shai Almog

unread,
Jun 6, 2015, 2:00:34 AM6/6/15
to codenameone...@googlegroups.com, nickk...@gmail.com, ramalh...@gmail.com, nickk...@gmail.com
Hi,
for the builtin scanner you can use:
Display.getInstance().setProperty("android.scanTypes", "CODE_128");



Which should improve this.

David Ramalho

unread,
Jun 6, 2015, 4:25:43 PM6/6/15
to Shai Almog, codenameone...@googlegroups.com, nickk...@gmail.com
Thank you very much Shai and Nick!
Both solutions work fine!

Cheers,

David
Reply all
Reply to author
Forward
0 new messages