clean Up Alarm PendingIntent - Android Android OS

Android examples for Android OS:Alarm Information

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  w  w . j  a v  a  2  s  .  c o m
        for (int i = 0; i < arr.length; i++) {
            am.cancel(arr[i]);
        }
    }
}

Related Tutorials