同じBroadcastReceiverに2つのアラームを登録できます。しかし、最初の警報は決して発射されません。どうすればこの作品を作れますか?同じBroadcastReceiverに設定されたAlarmManagerは機能しません
Calendar now = Calendar.getInstance();
now.set(Calendar.SECOND, now.get(Calendar.SECOND) + 5);
long trigger1 = now.getTimeInMillis();
now.set(Calendar.SECOND, now.get(Calendar.SECOND) + 10);
long trigger2 = now.getTimeInMillis();
Intent startIntent = new Intent(AlarmStartReceiver.START_ALARM);
startIntent.putExtra(AlarmStartReceiver.EXTRA_ALARM_ID, 4);
PendingIntent startPIntent = PendingIntent.getBroadcast(context, 0, startIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Intent startIntent2 = new Intent(AlarmStartReceiver.START_ALARM);
startIntent2.putExtra(AlarmStartReceiver.EXTRA_ALARM_ID, 5);
PendingIntent startPIntent2 = PendingIntent.getBroadcast(context, 0, startIntent2, PendingIntent.FLAG_UPDATE_CURRENT);
AlarmManager alarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarm.set(AlarmManager.RTC_WAKEUP, trigger1, startPIntent);
alarm.set(AlarmManager.RTC_WAKEUP, trigger2, startPIntent2);
2番目のものだけがオフになります。どうすればそれらを両方とも離させることができますか?
回答を編集する:requestCodeを一意に設定します。 PendingIntent.getBroadcastメソッドの第2パラメータ android pending intent notification problem