android8开始发送给静态广播需要明确设置ComponentName 参数
android8开始为静态广播设置ComponentName/**
* 其中ComponentName(参数1,参数2)
* 参数1指的是你的app的包名,参数2指的是你的自定义广播所在的路径
*
*/
Intent intent = new Intent();
intent.setAction(MqReceiver.Mq_Message);
//写法一
ComponentName componentName = new ComponentName("com.btzh.baidulocation","com.btzh.baidulocation.receiver.MqReceiver");
//写法二
//ComponentName componentName = new ComponentName(this,"com.btzh.baidulocation.receiver.MqReceiver");
intent.setComponent(componentName);
sendBroadcast(intent);
网友评论