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.

 

 

12 pensieri su “Barcodes. Do you use them?

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

    • … and I believe the link you provided supports camera scanning only. Am I missing something?
      I am trying to figure out how to scan using external wire-attached barcode scanner. Imagine an iPad in a docking station, the station is connected to the scanner. User uses scanner to scan a barcode that could represent anything, say user ID and password for employees. Scanned user Id shows in User ID field in a Xamarin.Forms application running on iPad. Similarly for Android and UWP devices.

      "Mi piace"

  2. No, not iOS native. I dont use XCode or ObjectiveC or Swift. I use Visual Studio for Mac and C# and Xamarin.Forms. So, unfortunatelly the ioS native link wont help.
    How do I connect iPad? Using cable. I know of your article explaining working with bluetooth but I dont have a bluetooth device
    Not sure why you think it is hard to connect Apple devices to externals though, I am doing it but I will take a look what MFI is

    "Mi piace"

  3. … btw, I see your bluetooth example is using only Android devices.
    What scanner is it and why only Android?
    I am open considering bluetooth scanners but I need support for primarily iOS, then Android, then UWP in that order of importance

    Much appreciated

    "Mi piace"

  4. @acaliaro Hi Alessandro, I am just kind of summarizing what I have been finding so far in terms of barcode scanners. It appears to me while handheld mobile devices with integrated scanners seem to usually have some kind of SDK provided or EMDK, the barcode readers (non mobile devices) seem to not have something like this (such as Xenon 19xx devices and other similar ones). Honeywell has not been able to provide any yet although they do claim they have.
    Would you agree with this statement re SDKs?

    Also, as far as I can see so far
    – Zebra supports only their own Android devices in Xamarin
    – ZXing supports only camera based scanning which is much slower and more appropriate for individuals rather than businesses scanning lots of items
    – Honeywell – no movement here at all – also seem to only support Android devices but unable to provide any instructions other than user manuals
    – Manateeworks seem to provide support for Xamarin Forms IOS, Android but it is paid licensing and have not explored this
    – Scanbot is also paid licensing, havent explored it either but it seems to support Xamarin Forms IOS, Android

    I used to work with few vendors with integrated barcode scanners (Motorola, Honeywell, Intermec, Trimble) few years back and at that time, vendor would provide some kind of Software Developer Manual to use the APIs they provide (such as Zebra’s EMDKManager, ScanDataCollection etc objects) but I dont seem to be finding anything for this in areas of handheld barcode readers.

    "Mi piace"

    • Yes I am agree. Handheld barcode scanners does not have Sdk. You should interact with them using SPP or HID protocols.

      Android devices should have an Sdk. Zebra has one, Datalogic has one, hintermec has one.

      For zebra, and for all devices that have DataWedge installed, you can use it to read barcodes without Sdk, only interact using Intents

      "Mi piace"

  5. Thanks, I know of your article for bluetooth on Android already, thanks for that. What is the MFI problem (sorry, I am new to this as you could probably already tell)?
    I would like to implement bluetooth scanner such as CS3000 (Motorolla) with my Xamarin Forms IOS and Android app

    "Mi piace"

  6. Additional info
    – Using vendor provided APIs (SDKs, EMDKs, libraries etc) seem to be problematic because if you support multiple vendors you have to deal with all the libraries they provide
    – Using keyboard emulation (basically handling your key-press events) is deceptive because you deal with 2 streams (scanner and keyboard) at one place and based on what I read like here in one of the comments (https://www.codeproject.com/Articles/296533/Using-a-bar-code-scanner-in-NET?fid=1670638&select=5543177&fr=26#xx0xx), causes more issues than it solves
    – Apparently serial is best but know nothing about that

    "Mi piace"

Rispondi

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

Logo di WordPress.com

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

Google photo

Stai commentando usando il tuo account Google. 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 )

Connessione a %s...