clean Up Alarm - Android android.app

Android examples for android.app:AlarmManager

Description

clean Up Alarm

Demo Code

import java.util.HashSet;

import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;

public class Main {

  public static HashSet<PendingIntent> set = new HashSet<PendingIntent>();
  static Context ctx;

  public static void cleanUp() {
    PendingIntent arr[] = new PendingIntent[set.size()];
    AlarmManager am = (AlarmManager) ctx.getSystemService(Context.ALARM_SERVICE);
    arr = set.toArray(arr);/*from w  w  w .  ja va  2s. c  om*/
    for (int i = 0; i < arr.length; i++) {
      am.cancel(arr[i]);
    }
  }

}

Related Tutorials