まったく同じPendingIntent
オブジェクトを持つ複数のアラームを設定していますが、それらのアラームが鳴る時間は異なります。同じIntent
オブジェクトをに提供して1つのアラームをキャンセルPendingIntent
し、これをに渡すとAlarmManager.cancel()
、すべてのアラームがキャンセルされますか(つまり、開始時刻が異なります)、それとも他の動作を示しますか?
コードは次のとおりです。
while(size != 0)
{
timeToSet = getNewTime(); //gets calendar object
Intent intent = new Intent(this, MyAlarmReceiver.class);
intent.putExtra("uniqueid", uuid);
intent.putExtra("vibrate", myalarm.getVibrate());
intent.putExtra("important", myalarm.getImportant());
PendingIntent pendingIntent = PendingIntent.getBroadcast(this.getApplicationContext(),
0, intent, PendingIntent.FLAG_UPDATE_CURRENT | Intent.FILL_IN_DATA);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, timeToSet.getTimeInMillis(), 604800000, pendingIntent);
size--;
}
したがって、Intentオブジェクトはすべてのアラームで同じですが、時間は異なります。これらのアラームをキャンセルすると、次のようになります。
Intent intent = new Intent(this, MyAlarmReceiver.class);
intent.putExtra("uniqueid", uuid);
intent.putExtra("vibrate", myalarm.getVibrate());
intent.putExtra("important", myalarm.getImportant());
PendingIntent pendingIntent = PendingIntent.getBroadcast(this.getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | Intent.FILL_IN_DATA);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.cancel(pendingIntent);
すべてのアラームはキャンセルされますか?それが私がやりたいことです。requestCode
私はすべてで異なるものを使用することができますが、PendingIntent
これらの余分なものを維持および保存したくないので、それらすべてがキャンセルされた方が良いでしょうrequestCodes
。
ありがとう!