cancel Alarm using Intent - Android Android OS

Android examples for Android OS:Alarm Set Up

Description

cancel Alarm using Intent

Demo Code


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

public class Main {
    public static void cancelAlarm(Context context, int index, String action) {
        Intent intent = new Intent(action);
        intent.putExtra("index", index);
        PendingIntent sender = PendingIntent.getBroadcast(context, index,
                intent, 0);//  w  w w .  j a v  a 2  s  . c o  m
        AlarmManager am = (AlarmManager) context
                .getSystemService(Context.ALARM_SERVICE);
        am.cancel(sender);
    }
}

Related Tutorials