List of usage examples for android.app AlarmManager cancel
public void cancel(OnAlarmListener listener)
From source file:com.andrewshu.android.reddit.mail.EnvelopeService.java
public static void resetAlarm(Context context, long interval) { // Create an IntentSender that will launch our service, to be scheduled // with the alarm manager. PendingIntent alarmSender = PendingIntent.getService(context, 0, new Intent(context, EnvelopeService.class), 0);//from w w w . j a v a2 s.c o m AlarmManager am = (AlarmManager) context.getSystemService(ALARM_SERVICE); am.cancel(alarmSender); if (interval != 0) am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), interval, alarmSender); }
From source file:com.alchemiasoft.book.receiver.SuggestionReceiver.java
/** * Schedule a suggestion alarm./*from www.java 2s . co m*/ * * @param context reference. * @return true if the alarm has been successfully scheduled, false otherwise. */ public static boolean scheduleSuggestion(Context context) { final AlarmManager alarmManager = AlarmUtil.getAlarmManager(context); if (sPendingIntent != null) { alarmManager.cancel(sPendingIntent); } final UserData userData = UserData.load(context); final UserData.SuggestionInterval interval = userData.suggestionInterval(); if (interval == UserData.SuggestionInterval.NEVER) { return false; } final Intent intent = new Intent(SUGGESTION_ACTION); sPendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); final long refreshInMills = interval.seconds() * DateUtils.SECOND_IN_MILLIS; Log.d(TAG_LOG, "AlarmReceiver: scheduling suggestion in " + interval.seconds() + " sec(s)."); alarmManager.set(AlarmManager.RTC, System.currentTimeMillis() + refreshInMills, sPendingIntent); return true; }
From source file:com.commonsware.android.job.PollReceiver.java
static void cancelAlarm(Context ctxt, AlarmManager alarms) { Intent i = new Intent(ctxt, PollReceiver.class); PendingIntent pi = PendingIntent.getBroadcast(ctxt, 0, i, 0); alarms.cancel(pi); }
From source file:nl.atcomputing.spacetravelagency.order.DepartureInfoService.java
static public void cancelDepartureInfoServiceAlarm(Context context) { Intent intent = new Intent(context, DepartureInfoService.class); PendingIntent pi = PendingIntent.getService(context, 1, intent, 0); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); am.cancel(pi); }
From source file:com.commonsware.android.deepbg.PollReceiver.java
static void cancelAlarm(Context ctxt, AlarmManager alarms) { Intent i = buildBaseIntent(ctxt);//from ww w . jav a2 s. c om PendingIntent pi = PendingIntent.getBroadcast(ctxt, 0, i, 0); alarms.cancel(pi); }
From source file:Main.java
public static void cancelAlarm(Context context, int alarmId, Intent intent) { AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); PendingIntent pi = PendingIntent.getBroadcast(context, alarmId, intent, PendingIntent.FLAG_UPDATE_CURRENT); alarmManager.cancel(pi); }
From source file:Main.java
public static void stopAlarm(AlarmManager manager, Context context, Class reciverClsss) { Intent intent = new Intent(context, reciverClsss); PendingIntent pintent = PendingIntent.getBroadcast(context, 0, intent, 0); manager.cancel(pintent); }
From source file:com.tealeaf.PushBroadcastReceiver.java
public static void disableNotifications(Context context) { if (scheduledIntent != null) { AlarmManager alarms = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarms.cancel(scheduledIntent); scheduledIntent = null;//from ww w .ja va2 s.c om } }
From source file:com.abid_mujtaba.bitcoin.tracker.services.FetchPriceService.java
public static void stop(Context context) // Method used to stop service via AlarmManager { Intent intent = new Intent(context, FetchPriceService.class); // Intent to launch service PendingIntent alarmIntent = PendingIntent.getService(context, 0, intent, 0); // PendingIntent required by AlarmManager. This gives the AlarmManager permission to launch this Intent as if it were being launched by this application AlarmManager amgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); amgr.cancel(alarmIntent); Logd("Stopping FetchPriceService."); }
From source file:Main.java
public static void stopServiceAlarm(Context context, Class<?> service) { AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(context, service); PendingIntent p = PendingIntent.getService(context, 10000, i, PendingIntent.FLAG_CANCEL_CURRENT); am.cancel(p); }