Note that there are some explanatory texts on larger screens.

plurals
  1. POCancelled alarm is shown to be up
    primarykey
    data
    text
    <p>I have read questions on stackoverflow on how to check if an alarm exists for a pending intent. </p> <p>I check if my alarm exists this way: </p> <pre><code>boolean alarmUp = (PendingIntent.getBroadcast(context, 0, new Intent("com.my.package.MY_UNIQUE_ACTION"), PendingIntent.FLAG_NO_CREATE) != null); </code></pre> <p>I set an alarm and check is it exist and then cancel the alarm. The alarm is actually cancelled but if run the above statement again, it still returns true. </p> <p>I have registered the broadcast receiver statically in manifest. </p> <p>My methods to set and cancel alarms are like this:</p> <pre><code> public static void cancelRecurringAlarm(Context context, String intentAction) { Logger.mlog(DEBUG_TAG, "cancelRecurringAlarm called with intent " + intentAction); Intent reminder = new Intent(); reminder.setClass(context, &lt;receiverClassName&gt;); reminder.setAction(intentAction); PendingIntent recurringReminder = PendingIntent.getBroadcast(context, 0, reminder, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager alarms = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarms.cancel(recurringReminder); } public static void setRecurringAlarm(String intentAction, Context context, long timeInMs) { Logger.mlog(DEBUG_TAG, "setRecurringAlarm called with intent " + intentAction); Intent reminder = new Intent(); reminder.setClass(context, &lt;receiverClassName&gt;); reminder.setAction(intentAction); PendingIntent recurringReminder = PendingIntent.getBroadcast(context, 0, reminder, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager alarms = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarms.setRepeating(AlarmManager.RTC, timeInMs, AlarmManager.INTERVAL_DAY, recurringReminder); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload