var main = plus.android.runtimeMainActivity(); //获取activity
var context = plus.android.importClass('android.content.Context'); //上下文
var receiver = plus.android.implements('io.dcloud.feature.internal.reflect.BroadcastReceiver', {
onReceive: function(context, intent) {
console.log('RECEIVE');
console.log(intent.getAction()); //获取action
//todo 这里应该怎么获取值?
main.unregisterReceiver(receiver); //取消监听
} //实现onReceiver回调函数
});
var IntentFilter = plus.android.importClass('android.content.IntentFilter'); //引入过滤器
var Intent = plus.android.importClass('android.content.Intent');
var filter = new IntentFilter();
filter.addAction('scan.rcv.message') //监听扫码广播
//filter.addDataScheme("package");
main.registerReceiver(receiver, filter); //注册监听
z***@163.com
- 发布:2018-05-12 11:18
- 更新:2018-05-12 11:18
- 阅读:2496
0 个回复