我在我的应用程序中使用BroadCast Receiver。我在我的应用程序中有很多活动。在MainActivity.java二手broadcard接收机如下:使用广播接收器在应用程序中的所有活动
private BroadcastReceiver smsReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// Retrieves a map of extended data from the intent.
final Bundle bundle = intent.getExtras();
try {
if (bundle != null) {
}
} catch (Exception e) {
e.printStackTrace();
}
}
};
我当消息即将到来,MyActivity在焦点通知。 现在当我的其他活动焦点时,我没有得到通知。 有没有一种常见的方式使用BroadCast的东西作为全球性的方式?为所有活动?
你在哪里注册/取消注册此接收器? – earthw0rmjim
您是否在'manifest.xml'中注册了receiver? –
@ MainActivity的earthw0rmjim OnREsume()和OnPause()。 – AskingToStack