Android 高版本 发送应用内广播

Android 高版本 发送应用内广播

在开发中,需要使用广播进行数据传递
但是,在 8.0 以后,不允许多个app之前发送广播,

google 应该是为了省电,做了这样的限制,尤其是在目前,限制app 之间的广播可以有效阻止他们相互唤醒

Android 8.0 以后发送广播

需要使用如下方式

Intent intent = new Intent(Constant.REMOTE_SERVICE_START_ACTION);
intent.setComponent(new ComponentName("com.zhou.example.messagelisenterservice",        "com.zhou.example.messagelisenterservice.StartReceive"));sendBroadcast(intent);

需要使用 ComponentName指定 app的名称和广播接收的 action 。

你可能感兴趣的:(Android 高版本 发送应用内广播)