android - 在 DataWedge 中以编程方式禁用扫描仪
问题描述
实际上我使用Output Intent
fromDataWedge
将解码后的数据发送到我的应用程序,所以在应用程序中记录了一个 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上写了一篇关于此的开发人员文章
推荐阅读
- javascript - 如何从使用带有模态的 EJS 获取数据
- arrays - Mongoose updateOne(不使用 $set)将子文档数组设置为 [](擦除数组中的每个子文档)
- python - Keras 中的时期和批次控制
- react-native - React-Native Imported Component 未在父状态更改时初始化其状态
- c - 如何在C中生成一个8位随机数>
- python - 为数据框分配一个新的 col
- asp.net - 将一组参数传递给网站的最佳方式是什么?
- angular - angular 2材质表刷新
- sql - Oracle SQL 动态数据透视
- oauth - 用户在asp .net core中授权时如何处理