title: Android how to cancel AlarmManager.setAlarmClock()
body: <p>There is this <a href="http://developer.android.com/reference/android/app/AlarmManager.html#setAlarmClock(android.app.AlarmManager.AlarmClockInfo,%20android.app.PendingIntent)" rel="noreferrer">new AlarmManager.setAlarmClock(...) method</a> in API 21, which sets a new alarm and displays a status bar alarm icon.</p>
  
  <p>I use it like this:</p>
  
  <pre><code>AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
  Intent intent = new Intent(ALARM_ALERT_ACTION);
  PendingIntent sender = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
  am.setAlarmClock(new AlarmManager.AlarmClockInfo(time, sender), sender);
  </code></pre>
  
  <p>The problem is that I don't know how to cancel this alarm, because this code doesn't work:</p>
  
  <pre><code>am.cancel(PendingIntent.getBroadcast(context, 0, new Intent(ALARM_ALERT_ACTION), PendingIntent.FLAG_CANCEL_CURRENT));
  </code></pre>
  
  <p>The alarm itself is cancelled (my BroadcastReceiver's onReceive is not called) but the status bar alarm icon is still displayed and also AlarmManager.getNextAlarmClock() returns this alarm.</p>