<script type="text/javascript" src="js/common.js"> </script>
<script>
mui.plusReady(function() {
var receiver;
main = plus.android.runtimeMainActivity(); //获取activity
receiver = plus.android.implements('io.dcloud.android.content.BroadcastReceiver', {
onReceive: function(context, intent) { //实现onReceiver回调函数
// alert(1);
plus.android.importClass(intent); //通过intent实例引入intent类,方便以后的‘.’操作
alert(intent.getStringExtra("scannerdata")); //获取数据
// main.unregisterReceiver(receiver); //取消监听
}
});
var IntentFilter = plus.android.importClass('android.content.IntentFilter');
var Intent = plus.android.importClass('android.content.Intent');
var filter = new IntentFilter();
filter.addAction("com.android.server.scannerservice.broadcast"); //监听扫码广播
main.registerReceiver(receiver, filter); //注册监听
console.log('ok');
});
</script>
改自 http://ask.dcloud.net.cn/article/12822
//监听扫码广播
//获取数据
以上数据测试用东大集成pda
mui 接收系统广播
有问题联系本人qq 659760615
common.js下载地址 点个star 谢谢啦
https://gitee.com/czxhehe/broadcasting/tree/master/