Barcodes. Do you use them?

The answer is obviously YES. Who don’t use barcodes? I don’t say in you apps, but in your life. Everywhere there are barcodes. On your bottle of milk, on your pack of spaghetti, on your newspaper, on your Xamarin Forms book.

This representation was born in 1960s and it is still the most widely used identification technology. Other technologies, like RFID or “new” beacons are used, but it’s hard for them to replace barcodes in a short time.

One of the most used barcode type is 2D like DataMatrix or QRCode.

A lot of apps have the capability to read barcodes and Xamarin Forms has some component that help you to manage these situations.

Xamarin Forms components

Here a list of components you can use with Xamarin Forms to read barcodes. This component use Camera as barcode reader. If you have a device with integrated barcode scanner, you should use device’s API to manage the scanner. It is interesting to note that often these libraries are derived from binding of other libraries (such as Java libraries. One day we will talk about Binding Java Libraries to use in Xamarin).

ZXing

ZXing is a C#/.NET library based on the open source Barcode Library: ZXing (Zebra Crossing), using the ZXing.Net Port. It works with Xamarin.iOS, Xamarin.Android, and Windows Phone. It’s open source. The author is Redth. I have used it in a couple of apps and it works fine.

Here a piece of code:

buttonScan.Click += (sender, e) => {

    #if __ANDROID__
    // Initialize the scanner first so it can track the current context
    MobileBarcodeScanner.Initialize (Application);
    #endif

    var scanner = new ZXing.Mobile.MobileBarcodeScanner();

    var result = await scanner.Scan();

    if (result != null)
        Console.WriteLine("Scanned Barcode: " + result.Text);
};

Rb.Forms.Barcode

Another open source library is Rb.Forms.Barcode. I have never used it but it should provides continuous scanning, aims to give high control to the user combined with high stability. If fact, the big problem of libraries that use Camera as scanner, is the read speed.

Very easy to use:

 

  • Create an instance of the BarcodeScanner class. Don’t forget to give it a height and width.
  • Register an EventHandler for the BarcodeScanner.BarcodeChanged event to receive the detected barcodes.

Here a working sample!

Motorola SDK

As I said previously, there are some devices that have an integrated scanner. Motorola TC70 has an integrated scanner and I have used it for an Enterprise Retail App. If you have a device with integrated scanner, obviously you have to use it, not the camera, to read barcodes. The performance of an integrated scanner are X times better than camera.

How can we use this scanner in a Xamarin (Forms) app? Is it possible? Yes, if OEM has a SDK. Fortunately Motorola has a SDK for Xamarin (Android, because TC70 is an Android device, and can simply used in a Xamarin Forms app).

You can find it as a Component in Xamarin Component Store. There are also a lot of documentation where is explained how to use Scanner and also others functionalities.

EMDK is an Open Source project. You find sources on GitHub with some samples.

 

 

Annunci

Un pensiero su “Barcodes. Do you use them?

  1. Pingback: Connect a barcode reader to a Xamarin Forms app via Bluetooth | I am a programmer

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...