Getting product information from a scanned barcode in Android

3.8k views Asked by At

I am developing a simple barcode scanner app which scans a barcode and displays the product info.

Using Zbar library I am able to scan barcode and get the GTIN (barcode number) for any product.

How can I convert the scanned barcode data to actual product information that I can display to the user? Is there some API or library available to accomplish this?

2

There are 2 answers

0
Terry Burton On

Assuming that you are referring to the common Point Of Sale barcode formats these all carry some variant of a product identifier referred to as a Global Trade Identification Number (GTIN):

  • UPC-A - GTIN-12
  • UPC-E - Zero-suppressed GTIN-12 [*]
  • EAN-13 - GTIN-13
  • EAN-8 - GTIN-8

Each of these except GTIN-8 can be converted into a GTIN-14 by prefixing with "0"s. (GTIN-8 is a discrete number system that is not currently mapped into any part of the GTIN-14 number system.)

After which the "Lookup" part of the following answer applies:

https://stackoverflow.com/a/31760872/2568535

[*] A zero-suppressed GTIN-12 can be converted to twelve-digit format ("UPC-A") as described here: https://stackoverflow.com/a/31539006/2568535

0
Namrata Bagerwal On

You can use latest Barcode Scanning Apis provided as part of Google Play Services 7.8 version. It has Barcode class that provides displayValue, valueFormat, rawValue, url, phone, email, contactInfo etc all the information associated with Barcode which you can get and display to an End User. For more information, you can follow CodeLab, refer Github Sample.