【发布时间】:2016-07-13 14:01:37
【问题描述】:
我有使用 EMDK 的应用程序,我的测试设备是 TC55。 我成功创建了启用和接收扫描数据的代码。但我有不同的问题 - 当我扫描条形码并在我的片段扫描值中看到 EditText 字段时,总是在那里添加。即使输入字段没有焦点。
我不希望这种行为 - 我希望仅将扫描结果传递给应用程序的后端方法,而不是输入文本字段。
请帮忙
【问题讨论】:
标签: android barcode-scanner motorola-emdk
我有使用 EMDK 的应用程序,我的测试设备是 TC55。 我成功创建了启用和接收扫描数据的代码。但我有不同的问题 - 当我扫描条形码并在我的片段扫描值中看到 EditText 字段时,总是在那里添加。即使输入字段没有焦点。
我不希望这种行为 - 我希望仅将扫描结果传递给应用程序的后端方法,而不是输入文本字段。
请帮忙
【问题讨论】:
标签: android barcode-scanner motorola-emdk
在使用 Xamarin EMDK 数月后,我终于设法删除了此类功能。只需进入您的个人资料以添加击键功能并禁用所有击键功能。
【讨论】:
默认情况下,Zebra Technologies 的 Android 设备(如 TC55)配置为使用 DataWedge 插入条形码数据作为键盘输入事件。
这样,您的应用程序无需特定编码即可接收条形码数据。
DataWedge 包含一个配置文件系统,您可以在其中将应用程序包名称和活动与特定配置文件相关联,并通过 Intent 将数据发送到您的应用程序。您可以在 Zebra developer portal 尤其是 how to configure DataWedge 上找到更多相关信息。
除此之外,Zebra Technologies 会定期发布适用于 Java 和 Xamarin 的 EMDK,以支持从 Android 应用程序自动执行这些配置,并提供 a full Barcode Scanning API that allows your application to take full control of the hardware barcode scanner。
免责声明:我在 Zebra Technologies 工作。
【讨论】:
根据@GustavoBaiocchiCosta 的回答,以下是如何通过意图禁用击键:
public void setKeystrokeConfig(boolean enabled) {
// Keystroke plugin properties bundle
Bundle bParams = new Bundle();
bParams.putString("keystroke_output_enabled", enabled ? "true" : "false"); // <--
bParams.putString("keystroke_action_char", "9");
bParams.putString("keystroke_delay_extended_ascii", "500");
bParams.putString("keystroke_delay_control_chars", "800");
// Keystroke plugin bundle
Bundle bConfig = new Bundle();
bConfig.putString("PLUGIN_NAME", "KEYSTROKE");
bConfig.putBundle("PARAM_LIST", bParams);
// Main bundle properties
Bundle configBundle = new Bundle();
configBundle.putString("PROFILE_NAME", "Profile12");
configBundle.putString("PROFILE_ENABLED", "true");
configBundle.putString("CONFIG_MODE", "CREATE_IF_NOT_EXIST");
configBundle.putBundle("PLUGIN_CONFIG", bConfig);
// Send intent to DataWedge
Intent i = new Intent();
i.setAction("com.symbol.datawedge.api.ACTION");
i.putExtra("com.symbol.datawedge.api.SET_CONFIG", configBundle);
i.putExtra("SEND_RESULT", "true");
i.putExtra("COMMAND_IDENTIFIER", "KEYSTROKE_API");
this.sendBroadcast(i);
}
这可以防止使用条形码内容填充焦点输入字段。
查看API here
【讨论】: