main = plus.android.runtimeMainActivity(); //获取activity
var Intent = plus.android.importClass('android.content.Intent');
var intent = new Intent();
if (plus.device.model === 'TC26'){
var softScanTrigger = "com.symbol.datawedge.api.ACTION";
var extraData = "com.symbol.datawedge.api.SOFT_SCAN_TRIGGER";
intent.setAction(softScanTrigger);
intent.putExtra(extraData, "START_SCANNING");
main.sendBroadcast(intent, null);
var receiver;
try {
receiver = plus.android.implements('io.dcloud.android.content.BroadcastReceiver', {
onReceive: function(context, intent) { //实现onReceiver回调函数
plus.android.importClass(intent); //通过intent实例引入intent类,方便以后的‘.’操作
var data = intent.getStringExtra('com.symbol.datawedge.data_string');
}
});
}catch(e){
alert("扫码异常,请退出重试");
}
var IntentFilter = plus.android.importClass('android.content.IntentFilter');
var filter = new IntentFilter();
// com.symbol.datawedge.scan 为DataWedge文件设置内容
filter.addAction("com.symbol.datawedge.scan"); //监听扫码广播
main.registerReceiver(receiver, filter); //注册监听
}
油焖豆角
- 发布:2021-12-07 15:34
- 更新:2023-03-20 11:16
- 阅读:2158
5 个评论
要回复文章请先登录或注册
ctzyh
kl_____
油焖豆角 (作者)
油焖豆角 (作者)
kl_____