简体   繁体   English

使用带有 Delphi 10.3 Rio Firemonkey Android 应用程序的外部条码扫描器

[英]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.关于在 SO 中使用带有Delphi的条码扫描仪有几个问题,如果这是一个VCL Windows应用程序,就不会有什么戏剧性的问题,但似乎没有一个答案对我有用。 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.在我无法确保哪个控件具有焦点的VCL应用程序中,我将捕获KeyPreview所有键,并在获得CR 时,获取前面的值并检查它是否与产品条形码匹配。

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.不幸的是, Firemonkey表单没有KeyPreview ,我不能使用 FMX 表单的KeyDown事件,因为它有几个能够接收文本输入的控件,如果其中任何一个具有焦点,则该事件不会为表单触发.

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.这些问题都是基于扫描仪被配对为 HID,但作为我使用的摩托罗拉 CS3070 蓝牙扫描仪的一个选项,还有一个串行端口配置文件模式。 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.但是Android UI 中似乎没有任何东西可以表明平板电脑具有哪些“串行端口”,即使有,我也不知道如何连接和“侦听”该端口在Delphi Firemonkey应用程序中。

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.正如其他人所指出的, Android中的串行端口与Windows不同,看起来Delphi 10.3 Rio没有本地支持使用它们。

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 .查看Zebra网站,该网站出售重新命名的CS3070 ,他们的扫描仪有一个Android SDK ,虽然遗憾的是不是CS3070,但他们确实有一个用于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.在文档中,他们谈到使用蓝牙SNAPI (我认为是 USB/串行模式)进行连接,以及订阅扫描仪事件。

Is this something we can do from FireMonkey without an SDK?这是我们可以在没有 SDK 的情况下从FireMonkey做的事情吗?

most of barcode reader in android has an SDK driver and send data via a Broadcast intent. android 中的大多数条码阅读器都有一个 SDK 驱动程序并通过广播意图发送数据。 you should check in settings form if there's some info about it or inside the SDK.如果有关于它或 SDK 内部的一些信息,您应该检查设置表单。 You just need the activity and category name and some extra info inside intent.您只需要活动和类别名称以及 Intent 中的一些额外信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM