Android how to cancel AlarmManager.setAlarmClock() -


In API 21, this is what sets a new alarm and the status bar displays the alarm icon.

I use it like this:

  AlarmManager AM = (alarm manager) context.getSystemService (Context.ALARM_SERVICE); Intent = Intentional Intent (ALARM_ALERT_ACTION); Pending delegation sender = pending content.thebredcast (references, 0, feedback, pending entity.FLAG_CANCEL_CURRENT); Am.setAlarmClock (new AlarmManager.AlarmClockInfo (time, sender), sender);  

The problem is that I do not know how to cancel this alarm, because this code does not work:

  am.cancel (pendingIntent GetBroadcast (Reference, 0, New Intent (ALARM_ALERT_ACTION, Pending Provider.FLAG_CANCEL_CURRENT));  

The alarm has been canceled (my broadcaster receiver's receiver is not called), but the status bar alarm icon is still displayed and the alarmmanager.getNextAlarmClock () this alarm gives.

pending agent FLAG_CANCEL_CURRENT says, "Cancel current pending . Conflicts AlarmManager when you go to cancellation , and in a confused alarm manager is never a good thing.

Only when you have a clear reason for doing this, use PendingIntent.FLAG_CANCEL_CURRENT . Do not use it as a default, "Oh, I'll use it instead of 0 , because I like to type in many characters" value: -)


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -