Bringing Barcodes to BlackBerry Applications


The Barcode Capture API included with BlackBerry® 6 comes with a nifty new feature: The ability for a third-party developer to integrate scanning and generating 1D and 2D barcodes inside their app. It’s really easy, too – take a look at this article in our Developer Resource Center to see a sample app that will generate QR codes, or scan them and open the URL in the browser.

If you have a device running BlackBerry® 6 you can compile the app and start playing around with it right now! If not, you may have noticed the new version of BlackBerry App World ™ (version 2.0) has a “Scan a Barcode” menu option. It’s nominally used to open links to apps in the App World, but it will do any URL encoded in a QR Code. Try this one:

QR Codes, if you have never encountered them before, are a type of 2D barcode. This is in contrast to a 1D barcode like the UPCs you see on most products. The big advantage of 2D barcodes (and QR codes in particular) is that they are easy to scan with a camera and can contain a lot of information. QR codes can hold up to 4296 alphanumeric characters, leaving you plenty of space for URLs or other bits of text data. 1D codes are more difficult to detect, and must be viewed straight on by the camera. This means that on a BlackBerry® Torch™ 9800 smartphone, you actually have to rotate the device into landscape mode to detect them properly. QR codes use those squares in the corner to make it easy to figure out the proper orientation.

They are pretty popular in the mobile space, so if you are interested in doing stuff with barcodes, QR codes are probably the one you want. They aren’t the only kind of barcode available to you as a developer, however – we’ve used the open source ZXing library (pronounced “zebra crossing”) to add support for many different kinds of barcode:

QR Code
Data Matrix
PDF 417

UPC (A and E)
EAN (8 and 13)

The full list is always in the BarcodeFormat class. Currently, as per the ZXing library, Data Matrix and PDF 417 support is alpha quality. These, along with the ease of reading – and an already very large mobile presence – make QR codes the best choice for most applications. As I said, the Barcode API in BlackBerry 6 allows the BlackBerry smartphone to generate a QR code for you, but there are also several websites that will help you do that as well (if you want to print them off, for example) such as here.

Finally, you might be interested to know that the package is actually very powerful, letting you get down into the nitty-gritty barcode data if you want. You can play around with the bit matrix used to generate 2D barcodes, and it also offers a few nifty methods like a Reed-Solomon encoder and decoder.

And don’t forget, even if you don’t need to use QR codes inside your application, with the function already built into BlackBerry App World they are a great way to promote your app. Just make one using your app’s URL in BlackBerry App World, and if a user sees it on a billboard or in a magazine, they can scan it and buy it right away.

Have you had any experience with the Barcode API yet? What did you think of it?

About Paul Bernhardt

I work for BlackBerry on the Developer relations team helping developers write apps in Cascades. I focus on camera, gaming and Unity mostly. My views are my own. In my free time, I'm a hardcore PC gamer and draw D&D maps for fun!

Join the conversation

Show comments Hide comments
+ -
  • TonyB

    Did you use the ZXing as is from Google? The source one google’s site is from 2008.

    If you did make changes it would be nice if RIM submitted patches, that way people developing for pre OS6 devices can use the ZXing library as well.

  • Chris Hallgren

    Also BBM 5 on any OS has support to scan barcodes and open the URL.

  • Uttam Bhatta

    If the barcode picture quality is not good, it is not able to scan. Till now i am not able to scan a single barcode using that sample. Is there any logic has been implemented to increase the picture quality, how RED Laser has been implemnted for iPhone…No use of this half API..Have anyone successfully able to scan any 39 code?

  • Saran Vonteddu

    hi can any send me the link to download the Zxing barcode APIs
    because I’v to develop barcode scanning application in bb 5.0 os,
    please somebody post the url……………………..

  • Sven

    Why is the MECARD not working?
    if you create “contact information” with it seems to be not supported??

  • td

    Do you have any plans to make this work better with 1D barcodes? If you take the sample and use it on a Torch, it does not work right unless you rotate the Torch sideways and hold it prefectly and the precise distance from the barcode.

    This is lame…as a developer I cannot use this in my application, and tell my users to rotate the camera, get the pergect lighting, and hold it exactly 8 inches from the barcode (and stand on their head:).

    Please work on this, as this is not usable at this point.

  • Julian

    This just does not work with my new BB Torch 9800, Camera cannot focus close enough to recognise the Bar Code, and just does not seem to work at all..:-(

  • rihan

    hey if nt using bb apps n using normal sim dn wats d rates 4 cals n msgs

  • Facebook Developer

    Another great tips to promote facebook fan page. I also read on your previous post. I mostly join other community and place my page URL

  • Cliff Hall

    Is this available in the tablet api?

  • Jay

    Hi Uttam,
    Yes I have managed to scan code 39 barcodes successfully [but still not as good as iPhone or Android though]. To get it to this level I had to spend a lot of time figuring things out for myself. As you correctly say, RIM there is no use of half APIs. We can’t build quality applications with stuff like this.
    It’s very hard to get a proper scan of Data Matrix or PDF 417. It’s better to say you don’t support it than users/customers complaining about it. Still no overlay control support for the viewfinder to help uses scan better. No proper control to the camera in barcode scanner mode.
    RIM/BlackBerry needs to catch up fast as most of the developers are moving to better platforms.

    Hi Julian,
    It works on the Torch, and it will only work on the Torch until other new devices come a long. It’s always advisable to scan all barcodes in Landscape [QR codes work Portrait as well], and as I have stated above I had to spend a lot of time to get it to work [at an acceptable level].

    Hi td,
    The sample app works just as you explain, but as I have stated above, need more work to get it to an acceptable level [personally I think it shouldn’t be the case if it was a proper implementation of barcode scanning].


  • Amelia Brooking

    It’s a nice idea and all, but all of the barcodes I try to scan on my Blackberry Curve 8520 seem to by too small for the scanner to focus on. Why is that?

  • Paul Leadbeater

    The App World Scanner works perfectly. Interestingly, the BB Messenger ‘Group Scan’ function does not work – it recognises the code but does nothing with it!

  • Raghurammadhu

    How do I scan a barcode in bold 9700? Can someone pls teach me?

  • Savourama

    Very helpful… thank-u

blog comments powered by Disqus