View source | Discuss this page | Page history | Printable version   

How to Support Barcode Scanner in Mobile Applications



Some mobile applications such as WebPOS or Mobile Warehouse Operations, benefit from the use of a barcode scanner as an input device.

This article explains what application changes are required to support it.

How Barcode Scanners Work

When a barcode scanner is connected (via USB or BlueTooth) to a mobile device it works as a hardware keyboard.

Depending on the device and its operating system, it might be required to put the focus in a text input field in order to be able to work with the scanner. Openbravo Mobile applications deal with them by setting the focus in an input text named focusKeeper that is positioned out of the screen. As said, the focusKeeper object is a HTML 'input' of type 'text'.

Configuring the Application to Work

In order to enable the focusKeeper, the application must configure it, otherwise the focus will not be set on it.

This is done by setting the global useBarcode terminal property to true. Each application can decide how this property should be set (as a backend configuration, fix for the whole application, asking the user to set it up in the UI, etc...)

As for the same application, there could be some windows (or even parts of a window) where the barcode scanner should be enabled and other ones where it should not. It is required to programmatically specify whether focusKeeper should be used. This is done by OB.MobileApp.view.scanningFocus(focus), the focus boolean parameter determines whether it should be used or not. If is to be used in the whole window, a good place to set it, is in its init method.

Behavior in Different Devices

The behavior of barcode scanners can vary depending on the scanner itself and, more often, in the mobile device hardware and operating system. This is the reason why it is highly advisable to test the application with the target devices.


Android < 4.2

Note that Chrome and the Stock browser behave differently.

Android >= 4.2

Retrieved from ""

This page has been accessed 11,370 times. This page was last modified on 26 December 2014, at 20:54. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.