ユーザー向けのメモのようなものを書いています。ユーザーはイベントのリマインダーを設定します。時間になると、繰り返しアラームが設定され、ステータス バー通知がトリガーされます。しかし、通知を選択したり、通知をクリアしたりした後、アラームが止まらないようです。この繰り返しアラームをキャンセルする場所がわかりません。以下にコードの一部を示します。 メイン アクティビティで繰り返しアラームを設定する
alarmTime = Calendar.getInstance();
Intent intent = new Intent(this, AlarmReceive.class);
PendingIntent sender = PendingIntent.getBroadcast(this, 0, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmTime.add(Calendar.MINUTE,offset_time);
//Schedule the alarm
alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, alarmTime.getTimeInMillis(), 30 * 1000, sender);
私の OnReceive メソッドでは、ステータス バーに通知を表示し、フラグを次のように設定するだけです。FLAG_AUTO_CANCEL
manager = (NotificationManager) context.getSystemService(context.NOTIFICATION_SERVICE);
// Set the icon, scrolling text and timestamp
Notification notification = new Notification(R.drawable.medical, text, System.currentTimeMillis());
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, i, 0);
notification.flags = Notification.FLAG_AUTO_CANCEL;
manager.notify(R.string.service_text, notification);
ユーザーが通知を選択またはクリアしたときにアラームを停止するにはどうすればよいですか?