Saturday 12 March 2016

HOW TO scan a barcode with Android smartphone camera from a web page

If you need a barcode to be scanned from a mobile web app & then get back the code as text from the scanner, the ZXing ("Zebra Crossing") open-source, multi-format 1D/2D barcode image processing library & ZXing Barcode Scanner can help.

Note that this web page will only work when opened within an Android browser & smartphone with camera having ZXing Barcode Scanner installed

Here are the steps for a simple demo:
1. Create a webpage to initiate the bar code scanner through anchor tag.

When the ZXing Barcode Scanner application is installed on an Android device, a URL call to: zxing://scan/?ret=http://example.azurewebsites.net/desc.html?code={CODE}
..will bring up the device bar code reader so that the user can scans the code. The code is returned via the callback URL parameter supplied in the zxing URL.
2. ZXing Barcode Scanner will present the code to the file desc.html. To show that the code is in fact returned, I use a document.write(location.href); to show the returned barcode text

2 comments:

  1. Thank you very much. I agree with your article, this really helped me. I appreciate your help. Thanks a lot. Good website.
    Smart Phone Barcode Reader

    ReplyDelete
  2. Zebra DS2208 BarCode Scanner in UAE, Zebra SR7U2100SGW Series BarCode Scanner in UAE, BarCode Scanner in UAE
    https://gccgamers.com/zebra-series.html
    Zebra DS2208 Scanner in UAE, Safe Shopping Multiple Payment Options Express Delivery GCC Gamers Moneyback Guarantee.
    1633921191080-9

    ReplyDelete