请问发送广播为啥还要指定接收广播的AlarmReceiver ?按理说,广播发出去,哪个类愿意接收就接收,那如果有多个Receiver接收,难道还带多个Receiver参数?
Intent intent = new Intent(this, AlarmReceiver.class);
intent.setAction("com.alarm.notice");
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
这个要看场景,如果你不指定接收广播的接收器,系统会将广播发送给所有注册了相应的接收器的应用程序,这可能会导致不必要的资源浪费和安全问题。