在DataWedge中以编程方式禁用扫描仪



实际上,我使用DataWedge中的Output Intent将解码数据发送到我的应用程序,因此在应用程序中记录了一个BroadcastReceiver,它可以获得解码数据

private BroadcastReceiver myBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (Objects.equals(action, getResources().getString(R.string.activity_intent_filter_action))) {
//  Received a barcode scan
try {
displayScanResult(intent);
} catch (Exception e) {
//  Catch if the UI does not exist when we receive the broadcast
}
}
}
};

问题是,在不使用EMDK的情况下,是否有可能以某种方式禁用扫描仪?如果以下条件成立,我可以禁用扫描:

if(Alerts.dialogError != null && Alerts.dialogError.isShowing()){
// Here i should block the scanner
}

是的,有两种方法,最简单的是:

Intent dwIntent = new Intent();
dwIntent.setAction("com.symbol.datawedge.api.ACTION");
//  Enable
dwIntent.putExtra("com.symbol.datawedge.api.SCANNER_INPUT_PLUGIN", "ENABLE_PLUGIN");
//  or Disable
dwIntent.putExtra("com.symbol.datawedge.api.SCANNER_INPUT_PLUGIN", "DISABLE_PLUGIN");
sendBroadcast(dwIntent);

为了了解更多上下文,我刚刚在https://developer.zebra.com/blog/quickly-suspend-scanning-your-app-datawedge

API通用文档可在以下网址获取:https://techdocs.zebra.com/datawedge/latest/guide/api/

扫描仪输入插件的文档如下:https://techdocs.zebra.com/datawedge/latest/guide/api/scannerinputplugin/

自DataWedge 13.0起,以下代码用于启用/禁用扫描仪输入插件:

private void enableScanner() {
Intent i = new Intent();
i.setAction("com.symbol.datawedge.api.ACTION");
i.putExtra("com.symbol.datawedge.api.SCANNER_INPUT_PLUGIN", "ENABLE_PLUGIN");
i.putExtra("SEND_RESULT", "true");
i.putExtra("COMMAND_IDENTIFIER", "MY_ENABLE_SCANNER");  //Unique identifier
this.sendBroadcast(i);
}
private void disableScanner() {
Intent i = new Intent();
i.setAction("com.symbol.datawedge.api.ACTION");
i.putExtra("com.symbol.datawedge.api.SCANNER_INPUT_PLUGIN", "DISABLE_PLUGIN");
i.putExtra("SEND_RESULT", "true");
i.putExtra("COMMAND_IDENTIFIER", "MY_DISABLE_SCANNER");  //Unique identifier
this.sendBroadcast(i);
}

相关内容

  • 没有找到相关文章

最新更新