List of usage examples for android.app AlarmManager cancel
public void cancel(OnAlarmListener listener)
From source file:com.kubotaku.android.code4kyoto5374.util.AlarmService.java
/** * ?/*from w w w.j a v a 2 s . c o m*/ * * @param context * @param garbageType ?? */ public static void cancelAlarm(Context context, final int garbageType) { final Intent intent = createIntent(context, garbageType); final PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); final AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.cancel(pendingIntent); }
From source file:net.kourlas.voipms_sms.receivers.SynchronizationIntervalReceiver.java
public static void setupSynchronizationInterval(Context applicationContext) { Preferences preferences = Preferences.getInstance(applicationContext); AlarmManager alarmManager = (AlarmManager) applicationContext.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(applicationContext, SynchronizationIntervalReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(applicationContext, 0, intent, 0); alarmManager.cancel(pendingIntent); long syncInterval = preferences.getSyncInterval() * (24 * 60 * 60 * 1000); if (syncInterval != 0) { long nextSyncTime = preferences.getLastCompleteSyncTime() + syncInterval; long now = System.currentTimeMillis(); if (nextSyncTime <= now) { Database.getInstance(applicationContext).synchronize(false, false, null); nextSyncTime = now + syncInterval; }/*from w w w.j a va2s. c o m*/ alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, nextSyncTime, syncInterval, pendingIntent); } }
From source file:br.ajmarques.cordova.plugin.localnotification.LocalNotification.java
/** * Cancel a specific notification that was previously registered. * * @param notificationId/*w w w.java 2s . com*/ * 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) { } }
From source file:com.licenta.android.licenseapp.alarm.AlarmReceiver.java
public static void cancelAlarm(Context context) { AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, AlarmReceiver.class); PendingIntent alarmIntent = PendingIntent.getBroadcast(context, 0, intent, 0); //if (alarmManager!= null) { alarmManager.cancel(alarmIntent); PreferenceManager.getDefaultSharedPreferences(context).edit() .putBoolean(Constants.PREF_KEY_IS_ALARM_ON, false).apply(); Log.d(context.getClass().getName(), "Alarm stopped"); //}/* w w w.j a v a 2 s . c o m*/ }
From source file:com.chess.genesis.net.GenesisNotifier.java
private static void CancelWakup(final Context context) { final Intent intent = new Intent(context, GenesisAlarm.class); final PendingIntent pintent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); final AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); am.cancel(pintent); }
From source file:com.google.android.apps.dashclock.PeriodicExtensionRefreshReceiver.java
/** * Cancels the refresh schedule if one isn't set already. *//*from w w w. j av a 2 s .co m*/ protected static void cancelPeriodicRefresh(final Context context) { final AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); PendingIntent pi = PendingIntent.getBroadcast(context, 0, new Intent(context, PeriodicExtensionRefreshReceiver.class).setAction(ACTION_PERIODIC_ALARM), PendingIntent.FLAG_CANCEL_CURRENT); am.cancel(pi); }
From source file:com.chintans.venturebox.util.Utils.java
public static void setAlarm(Context context, long time, boolean trigger, boolean isRom) { Intent i = new Intent(context, NotificationAlarm.class); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pi = PendingIntent.getBroadcast(context, isRom ? ROM_ALARM_ID : GAPPS_ALARM_ID, i, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); am.cancel(pi); if (time > 0) { am.setInexactRepeating(AlarmManager.RTC_WAKEUP, trigger ? 0 : time, time, pi); }//from www. j ava2 s . c om }
From source file:ch.fixme.status.Widget.java
protected static void setAlarm(Context ctxt, Intent i, int widgetId, int delay) { // Get interval SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctxt); long update_interval = Long .parseLong(prefs.getString(Prefs.KEY_CHECK_INTERVAL, Prefs.DEFAULT_CHECK_INTERVAL)) * 60L * 1000L; // Set alarm/*from w w w . j a va 2 s.c om*/ AlarmManager am = (AlarmManager) ctxt.getSystemService(Context.ALARM_SERVICE); PendingIntent pi = PendingIntent.getService(ctxt, widgetId, i, 0); am.cancel(pi); am.setRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + delay, update_interval, pi); // Log.i(Main.TAG, "start notification every " + update_interval / 1000 // + "s"); }
From source file:com.cyanogenmod.account.util.CMAccountUtils.java
public static void cancelCMAccountPing(Context context, Intent intent) { if (CMAccount.DEBUG) Log.d(TAG, "Canceling CMAccount 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:com.lloydtorres.stately.push.TrixHelper.java
/** * Cancels any previous alarms set for Alphys. * @param c App context.//from ww w .jav a 2 s . co m */ public static void stopAlarmForAlphys(Context c) { Intent alphysIntent = new Intent(c, AlphysService.class); PendingIntent pendingIntent = PendingIntent.getService(c, 0, alphysIntent, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager am = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE); am.cancel(pendingIntent); }