Search code examples
androidbarcode-scannerandroid-hardware

Android: How to integrate External BarCode Scanner device connected via USB to Android Application


I am developing POS application for shop. The Shop keeper can use any brand of BarCode Scanner devices. I need to get the details of the scanned item. Is there any library file available for the same.

FYI

  • External barcode scanner is connected to the device via USB.

  • I need the event to fetch the data scanned and sent from the scanner.


Solution

  • i think every single barcode scanner have integration support for android, but what i need is to give common support for all or more external barcode scanners.

    It sounds like you are looking for something that you yourself admit doesn't exist. There isn't a common standard that ALL scanners implement for proper Android integration. That said, here's how you can achieve your two goals

    Any Brand: Most barcode scanners support HID mode, which is basically just connecting as a keyboard; this is how practically all USB scanners work. Using HID mode the scanner will "type" the barcode wherever the cursor is located, which doesn't give you much control.

    End event: Again, most barcode scanners can be configured to append a trailing character. Usually it defaults to a carriage return or tab. In your activity or view you can set an onKeyListener and in that listener you watch for the KEY_DOWN event of your trailing character which indicates the end of a scan.

    Using HID and trailing character detection you will be able to support most wired and wireless scanners