SiBrit
SiBrit

Reputation: 1532

Using an external barcode scanner with a Delphi 10.3 Rio Firemonkey Android app

There are a few questions about using a barcode scanner with Delphi in SO, and if this was a VCL Windows application there would be no drama, but none of the answers seem to work for me. This is also about using an external scanner and not using the devices camera to scan barcodes, as that is also a doddle.

In a VCL app where I couldn't ensure which control has the focus, I would capture all the keys in KeyPreview, and on getting a CR, take the preceding value and check to see if it matches a product barcode.

Unfortunately, Firemonkey forms have no KeyPreview and I can't use the KeyDown event of the FMX form, as it has several controls capable of receiving text input, and if any of them have the focus, the event doesn't fire for the form.

These problems are all based on the scanner being paired as a HID, but as an option on the Motorola CS3070 Bluetooth scanner I am using, there is also a Serial Port Profile mode. It still pairs with the tablet, but not as a keyboard.

But there doesn't seem to be anything in the Android UI to indicate what "serial ports" the tablet has, and even if it did, I don't really have any idea on how to connect to and "listen" to that port inside a Delphi Firemonkey app.

As others have indicated, serial ports in Android are a different beast to Windows, and it looks like Delphi 10.3 Rio has no native support for using them.

What other options are there?

EDIT:

Looking at the Zebra website, which sell a re-branded CS3070, there is an Android SDK for their scanners, although sadly not for the CS3070 but they do have one for the CS4070. In the documentation they talk about connecting using BlueTooth or SNAPI (which I believe is the USB/serial mode), and also about subscribing to the scanner events.

Is this something we can do from FireMonkey without an SDK?

Upvotes: 0

Views: 1638

Answers (1)

drcrck
drcrck

Reputation: 11

most of barcode reader in android has an SDK driver and send data via a Broadcast intent. you should check in settings form if there's some info about it or inside the SDK. You just need the activity and category name and some extra info inside intent.

Upvotes: 0

Related Questions