嗨,我正在尝试取消 AlarmManager。我写了一些测试代码,但它不起作用,我的代码:
警报创建:
Intent myIntent = new Intent(this,NotificationService.class);
PendingIntent pendingIntentFriday = PendingIntent.getService(this,123098,myIntent, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP,nextFriday.getTimeInMillis() , pendingIntentFriday);
报警取消:
Intent stopIntent = new Intent(this,NotificationService.class);
PendingIntent stopFriday = PendingIntent.getService(this,123098,stopIntent, PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager stopManager = (AlarmManager) getSystemService(ALARM_SERVICE);
stopManager.cancel(stopFriday);