clean Up Alarm PendingIntent - Android Intent

Android examples for Intent:Alarm Intent

Description

clean Up Alarm PendingIntent

Demo Code


//package com.java2s;

import java.util.HashSet;
import android.app.AlarmManager;
import android.app.PendingIntent;

import android.content.Context;

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

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

Related Tutorials