cancel Alarm Update Broadcast - Android Android OS

Android examples for Android OS:Alarm Cancel

Description

cancel Alarm Update Broadcast

Demo Code


//package com.java2s;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;

public class Main {
    private static String CODE = "intent_code";

    public static void cancelUpdateBroadcast(Context context) {
        AlarmManager am = getAlarmManager(context);
        Intent i = new Intent(CODE);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(context,
                0, i, 0);//from  ww w  . j  a  va  2  s. co m
        am.cancel(pendingIntent);
    }

    public static AlarmManager getAlarmManager(Context context) {
        return (AlarmManager) context
                .getSystemService(Context.ALARM_SERVICE);
    }
}

Related Tutorials