List of usage examples for android.app AlarmManager cancel
public void cancel(OnAlarmListener listener)
From source file:com.phonemetra.account.util.AccountUtils.java
public static void cancelAccountPing(Context context, Intent intent) { if (Account.DEBUG) Log.d(TAG, "Canceling Account ping"); PendingIntent reRegisterPendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); am.cancel(reRegisterPendingIntent); }
From source file:de.hero.vertretungsplan.MainActivity.java
public static void setNewAlarm(Context context, boolean set, String interval) { Intent i = new Intent(context, de.hero.vertretungsplan.CheckForUpdates.class); PendingIntent pi = PendingIntent.getService(context, 0, i, 0); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); am.cancel(pi); // cancel any existing alarms Log.d("MainActivity", "cancelAlarm"); if (set) {/*from ww w. j a v a 2s .co m*/ long lngInterval; switch (interval) { case "1/2": lngInterval = AlarmManager.INTERVAL_HALF_HOUR; break; case "1": lngInterval = AlarmManager.INTERVAL_HOUR; break; case "6": lngInterval = AlarmManager.INTERVAL_HALF_DAY / 2; break; case "3": default: lngInterval = AlarmManager.INTERVAL_HOUR * 3; break; } Log.d("MainActivity", "setAlarm " + interval + " Stunden"); am.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + AlarmManager.INTERVAL_HALF_HOUR / 3, lngInterval, pi); // For debugging after 10 seconds // am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, // SystemClock.elapsedRealtime() + 25000 , // AlarmManager.INTERVAL_HOUR , pi); } }
From source file:com.fanfou.app.opensource.service.DownloadService.java
public static void unset(final Context context) { final AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); am.cancel(DownloadService.getPendingIntent(context)); if (AppContext.DEBUG) { Log.d(DownloadService.TAG, "unset"); }// w w w.j av a 2s .c o m }
From source file:com.footprint.cordova.plugin.localnotification.LocalNotification.java
/** * Cancel a specific notification that was previously registered. * * @param notificationId// ww w . j a v a 2s .c o m * The original ID of the notification that was used when it was * registered using add() */ public static void cancel(String notificationId) { /* * Create an intent that looks similar, to the one that was registered * using add. Making sure the notification id in the action is the same. * Now we can search for such an intent using the 'getService' method * and cancel it. */ Intent intent = new Intent(context, Receiver.class).setAction("" + notificationId); PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, 0); AlarmManager am = getAlarmManager(); NotificationManager nc = getNotificationManager(); am.cancel(pi); try { nc.cancel(Integer.parseInt(notificationId)); } catch (Exception e) { } fireEvent("cancel", notificationId, ""); }
From source file:com.bangalore.barcamp.BCBUtils.java
public static void removeSessionFromSchedule(Context context, String sessionid, int slotPos, int sessionPos) { BCBSharedPrefUtils.setAlarmSettingsForID(context, sessionid, BCBSharedPrefUtils.ALARM_NOT_SET); PendingIntent intent = BCBUtils.createPendingIntentForID(context, sessionid, slotPos, sessionPos); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.cancel(intent); }
From source file:com.cryart.sabbathschool.util.SSNotification.java
public static void cancelRepeatingNotification(Context context) { AlarmManager _SSAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent _SSUpdateServiceIntent = new Intent(context, SSBroadcastReceiver.class); PendingIntent _SSPendingUpdateServiceIntent = PendingIntent.getBroadcast(context, 0, _SSUpdateServiceIntent, 0);/* ww w .j a v a 2 s. c om*/ try { _SSAlarmManager.cancel(_SSPendingUpdateServiceIntent); } catch (Exception e) { } }
From source file:com.yeldi.yeldibazaar.UpdateService.java
public static void schedule(Context ctx) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); String sint = prefs.getString("updateInterval", "0"); int interval = Integer.parseInt(sint); Intent intent = new Intent(ctx, UpdateService.class); PendingIntent pending = PendingIntent.getService(ctx, 0, intent, 0); AlarmManager alarm = (AlarmManager) ctx.getSystemService(Context.ALARM_SERVICE); alarm.cancel(pending); if (interval > 0) { alarm.setInexactRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + 5000, AlarmManager.INTERVAL_HOUR, pending); Log.d("FDroid", "Update scheduler alarm set"); } else {//from www.j a va 2 s . c om Log.d("FDroid", "Update scheduler alarm not set"); } }
From source file:se.erichansander.retrotimer.RetroTimer.java
/** Cancels the alarm in the AlarmManager and updates app state */ public static void cancelAlarm(Context context) { // Cancel the alarm in AlarmManager AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); PendingIntent sender = PendingIntent.getBroadcast(context, 0, new Intent(RetroTimer.ALARM_TRIGGER_ACTION), PendingIntent.FLAG_CANCEL_CURRENT); am.cancel(sender); // Cancel the notification NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(RetroTimer.NOTIF_SET_ID);/*from www .j av a 2s .c o m*/ clearAlarm(context); }
From source file:de.wikilab.android.friendica01.Max.java
public static void cancelTimer(Context c) { Log.i("Friendica", "try cancelTimer"); if (piTimerNotifications == null) return;/*from w ww. j a v a 2s. c o m*/ AlarmManager a = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE); a.cancel(piTimerNotifications); piTimerNotifications = null; Toast.makeText(c, "Friendica: Notif. check timer cancel", Toast.LENGTH_SHORT).show(); Log.i("Friendica", "done cancelTimer"); }
From source file:vrisini.cordova.plugin.schedule.Schedule.java
/** * Cancel a specific notification that was previously registered. * * @param notificationId//from ww w . jav a2 s . co m * The original ID of the notification that was used when it was * registered using add() */ public static void cancel(String notificationId) { /* * Create an intent that looks similar, to the one that was registered * using add. Making sure the notification id in the action is the same. * Now we can search for such an intent using the 'getService' method * and cancel it. */ Intent intent = new Intent(context, Receiver.class).setAction("" + notificationId); PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager am = getAlarmManager(); NotificationManager nc = getNotificationManager(); am.cancel(pi); try { nc.cancel(Integer.parseInt(notificationId)); } catch (Exception e) { } fireEvent("cancel", notificationId, ""); }