我有一个正在声明警报的服务(AlarmService.java):
Intent intentAlarm = new Intent(this, TimeAlarm.class);
intentAlarm.putExtra("Notif_body", Notif_Body);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
PendingIntent displayIntent = PendingIntent.getBroadcast(getApplication(),1,intentAlarm, 0);
alarmManager.set(AlarmManager.RTC_WAKEUP,new GregorianCalendar().getTimeInMillis()+5*1000, displayIntent);
和一个活动(user_settings.java),一旦取消选中复选框,我想从中删除该警报:
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
Intent intentAlarm = new Intent(this,TimeAlarm.class);
PendingIntent displayIntent = PendingIntent.getBroadcast(getApplication(),1,intentAlarm, 0);
alarmManager.cancel(displayIntent);
但它不起作用我的警报没有被删除为什么虽然pendingintent与它应该是一样的!!