Android 通过科尔多瓦广播公司接收广播意向
我正在尝试使用插件来接收android广播意图。 我登记参加广播活动Android 通过科尔多瓦广播公司接收广播意向,android,cordova,android-intent,cordova-plugins,Android,Cordova,Android Intent,Cordova Plugins,我正在尝试使用插件来接收android广播意图。 我登记参加广播活动 window.broadcaster.addEventListener("com.android.action.SEND_SCAN_RESULT", function (e) { console.log("com.android.action.SEND_SCAN_RESULT received."); }); console.log("com.android.action.SEND_S
window.broadcaster.addEventListener("com.android.action.SEND_SCAN_RESULT", function (e) {
console.log("com.android.action.SEND_SCAN_RESULT received.");
});
console.log("com.android.action.SEND_SCAN_RESULT registered");
但是如果意图被激发
V/ActivityManager( 775): Broadcast: Intent { act=com.android.action.SEND_SCAN_RESULT flg=0x10 (has extras) } ordered=false userid=0 callerApp=ProcessRecord{1418277c 775:system/1000}
回调不会被触发
唯一的日志消息是
com.android.action.SEND\u扫描\u结果已注册
目前该插件不管理外部广播事件,而只管理本地广播事件 可能解决方案是在android中处理外部事件,然后将其激发到javascript 看一看 试试这个(应该有用) 清单
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<receiver android:name="MyReceiver" >
<intent-filter>
<action android:name="com.android.action.SEND_SCAN_RESULT" >
</action>
</intent-filter>
</receiver>
</application>
试试看。查找
intentShim.registerBroadcastReceiver
已接收广播,但额外信息为空,我们需要做些什么吗?检查您是否已将信息放入“userdata”字段,并且这些信息的json格式正确
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
LocalBroadcastManager.getInstance(context).sendBroadcastSync(intent);
}
}