Example usage for android.app AlarmManager cancel

List of usage examples for android.app AlarmManager cancel

Introduction

In this page you can find the example usage for android.app AlarmManager cancel.

Prototype

public void cancel(OnAlarmListener listener) 

Source Link

Document

Remove any alarm scheduled to be delivered to the given OnAlarmListener .

Usage

From source file:Main.java

public static void cancelAlarm(Context context, Intent intent, int notificationId) {
    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, notificationId, intent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    alarmManager.cancel(pendingIntent);
}

From source file:cat.wuyingren.whatsannoy.utils.SystemUtils.java

public static void cancelAlarm(Context context, Schedule schedule) {
    Intent intent = new Intent(context, Alarm.class);
    PendingIntent pi = PendingIntent.getBroadcast(context, SystemUtils.safeLongToInt(schedule.getId()), intent,
            0);//w  ww .j a  va 2s . c o m
    AlarmManager alarmMgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    alarmMgr.cancel(pi);
}

From source file:Main.java

public static void cancelAlarm(Context context, int id) {
    AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    Intent intent = new Intent("myAlarmClock");
    PendingIntent pdi = PendingIntent.getBroadcast(context, id, intent, PendingIntent.FLAG_CANCEL_CURRENT);
    am.cancel(pdi);
}

From source file:com.jmstudios.redmoon.receiver.AutomaticFilterChangeReceiver.java

public static void cancelPauseAlarm(Context context) {
    Intent commands = new Intent(context, AutomaticFilterChangeReceiver.class);
    commands.setData(Uri.parse("pauseIntent"));
    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, commands, 0);
    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    alarmManager.cancel(pendingIntent);
}

From source file:com.jmstudios.redmoon.receiver.AutomaticFilterChangeReceiver.java

public static void cancelTurnOnAlarm(Context context) {
    Intent commands = new Intent(context, AutomaticFilterChangeReceiver.class);
    commands.setData(Uri.parse("turnOnIntent"));
    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, commands, 0);
    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    alarmManager.cancel(pendingIntent);
}

From source file:Main.java

public static void cancel(Context context) {
    AlarmManager mAlarm = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    PendingIntent pintent = PendingIntent.getBroadcast(context, ALARM_REQUEST, new Intent(INTENT_FILTER_NAME),
            PendingIntent.FLAG_CANCEL_CURRENT);
    mAlarm.cancel(pintent);
}

From source file:Main.java

public static synchronized void cancelServiceAlarm(Context context, Intent intent, int identifier) {

    final AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    final PendingIntent pi = PendingIntent.getService(context, identifier, intent,
            PendingIntent.FLAG_NO_CREATE);
    if (pi != null) {
        am.cancel(pi);
        pi.cancel();//  ww  w  .  j  a  v a2s.c  o  m
    }

}

From source file:org.leopub.mat.service.MessageService.java

public static void cancelUpdate(Context context) {
    Intent i = new Intent(context, MessageService.class);
    PendingIntent pi = PendingIntent.getService(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT);
    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    alarmManager.cancel(pi);
    pi.cancel();/*from   w  w  w  .j  ava  2s.  c o  m*/
}

From source file:mchs.neverforget.services.NotificationIntentService.java

public static void cancelCustomRecurrentNotificationAlarm(Context context, int customId) {
    //Toast.makeText(context, "cancelCustomRecurrentNotificationAlarm"+customId, Toast.LENGTH_SHORT).show();
    Intent intent = new Intent(context, NotificationIntentService.class);
    if (customId == 1) {
        intent.setAction(ACTION_NOTIFY_CUSTOM1);
    } else if (customId == 2) {
        intent.setAction(ACTION_NOTIFY_CUSTOM2);
    } else if (customId == 3) {
        intent.setAction(ACTION_NOTIFY_CUSTOM3);
    }//www.  ja v  a2 s. com

    PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent,
            PendingIntent.FLAG_CANCEL_CURRENT);

    AlarmManager alarmManager = (AlarmManager) context.getSystemService(ALARM_SERVICE);
    alarmManager.cancel(pendingIntent);
}

From source file:Main.java

public static void closeService(Context context, Class<?> cls, String action) {
    AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    Intent intent = new Intent(context, cls);
    intent.setAction(action);/*from   w  ww .j a  va  2  s  .c  o m*/
    PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    alarmManager.cancel(pendingIntent);
}