List of usage examples for android.app AlarmManager cancel
public void cancel(OnAlarmListener listener)
From source file:MainActivity.java
public void cancelAlarm() { Intent intentToFire = new Intent(getApplicationContext(), AlarmBroadcastReceiver.class); intentToFire.setAction(AlarmBroadcastReceiver.ACTION_ALARM); PendingIntent alarmIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, intentToFire, 0); AlarmManager alarmManager = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); alarmManager.cancel(alarmIntent); }
From source file:org.hansel.myAlert.StopScheduleActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AlarmManager am = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); am.cancel(Util.getReminderPendingIntennt(getApplicationContext())); PreferenciasHancel.setAlarmStartDate(getApplicationContext(), 0); //ya se termino el tiempo de la programacin cancelamos alarma y salimos Log.v("Fin de la programacin"); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher).setContentTitle("Rastreo Finalizado") .setContentText("Gracias por usar Hancel"); Notification notif = mBuilder.build(); notif.flags = Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL; NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(0, notif); finish();/*from w w w . j a v a 2 s. co m*/ return; }
From source file:com.devnoobs.bmr.Powiadomienia.java
public void cancelAlarm() { Intent i = new Intent(S); PendingIntent sender = PendingIntent.getBroadcast(c, 0, i, 0); AlarmManager alarmManager = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE); alarmManager.cancel(sender); showToast("Powiadomienie wylaczone"); }
From source file:townley.stuart.app.android.trekkinly.AlertClass.java
@Override public void onReceive(final Context context, Intent intent) { NotificationItemClass notificationItemClass = new NotificationItemClass(); DataBaseHelper db = new DataBaseHelper(context); db.getWritableDatabase();//from www. ja v a 2s . c om db.getNotification(notificationItemClass); if (db.notification <= System.currentTimeMillis()) { createNotification(context, "Something is missing!", "Click here for more details!", "Alert"); ComponentName receiver = new ComponentName(context, AlertClass.class); PackageManager pm = context.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); intent = new Intent(context, AlertClass.class); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.cancel(PendingIntent.getBroadcast(context.getApplicationContext(), 1, intent, PendingIntent.FLAG_UPDATE_CURRENT)); } else if (db.notification > System.currentTimeMillis()) { intent = new Intent(context, AlertClass.class); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.set(AlarmManager.RTC_WAKEUP, db.notification, PendingIntent .getBroadcast(context.getApplicationContext(), 1, intent, PendingIntent.FLAG_UPDATE_CURRENT)); } }
From source file:de.schildbach.wallet.service.BlockchainService.java
public static void scheduleStart(final WalletApplication application) { final Configuration config = application.getConfiguration(); final long lastUsedAgo = config.getLastUsedAgo(); // apply some backoff final long alarmInterval; if (lastUsedAgo < Constants.LAST_USAGE_THRESHOLD_JUST_MS) alarmInterval = AlarmManager.INTERVAL_FIFTEEN_MINUTES; else if (lastUsedAgo < Constants.LAST_USAGE_THRESHOLD_RECENTLY_MS) alarmInterval = AlarmManager.INTERVAL_HALF_DAY; else/*from ww w.j av a 2 s. co m*/ alarmInterval = AlarmManager.INTERVAL_DAY; log.info("last used {} minutes ago, rescheduling blockchain sync in roughly {} minutes", lastUsedAgo / DateUtils.MINUTE_IN_MILLIS, alarmInterval / DateUtils.MINUTE_IN_MILLIS); final AlarmManager alarmManager = (AlarmManager) application.getSystemService(Context.ALARM_SERVICE); final PendingIntent alarmIntent = PendingIntent.getService(application, 0, new Intent(application, BlockchainService.class), 0); alarmManager.cancel(alarmIntent); // workaround for no inexact set() before KitKat final long now = System.currentTimeMillis(); alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, now + alarmInterval, AlarmManager.INTERVAL_DAY, alarmIntent); }
From source file:com.cpd.receivers.LibraryRenewAlarmBroadcastReceiver.java
public void cancelAlarm(Context context) { Log.d(TAG, "cancelAlarm() called with: " + "context = [" + context + "]"); Intent intent = new Intent(context, LibraryRenewAlarmBroadcastReceiver.class); PendingIntent sender = PendingIntent.getBroadcast(context, 1, intent, 0); AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); alarmManager.cancel(sender); }
From source file:com.google.android.apps.muzei.sync.TaskQueueService.java
private void cancelArtworkDownloadRetries() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { JobScheduler jobScheduler = (JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE); jobScheduler.cancel(LOAD_ARTWORK_JOB_ID); } else {/*from w w w . jav a 2 s . com*/ AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); am.cancel(TaskQueueService.getArtworkDownloadRetryPendingIntent(this)); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); sp.edit().putInt(PREF_ARTWORK_DOWNLOAD_ATTEMPT, 0).commit(); } }
From source file:com.sean.takeastand.alarmprocess.UnscheduledRepeatingAlarm.java
@Override public void cancelAlarm() { PendingIntent pendingIntent = createPendingIntent(mContext); AlarmManager am = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); am.cancel(pendingIntent); endAlarmService();/* www . j a v a 2s.c om*/ Utils.setImageStatus(mContext, Constants.NO_ALARM_RUNNING); }
From source file:com.sean.takeastand.alarmprocess.UnscheduledRepeatingAlarm.java
@Override public void unpause() { PendingIntent pendingIntent = createPausePendingIntent(mContext); AlarmManager am = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); am.cancel(pendingIntent); setRepeatingAlarm();//from w w w . j av a 2 s .co m Utils.setImageStatus(mContext, Constants.NON_SCHEDULE_ALARM_RUNNING); }
From source file:com.turkiyedenemeleri.chronometer.ForegroundService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent.getAction().equals(Constants.ACTION.STARTFOREGROUND_ACTION)) { PrefUtils mPreferences = new PrefUtils(this); long wakeUpTime = (mPreferences.getStartedTime(intent.getStringExtra("snavid")) + 1800) * 1000; /*//ww w . j ava 2 s . co m AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Intent timerExpire = new Intent(this, TimerExpiredReceiver.class); PendingIntent sender = PendingIntent.getBroadcast(this, 0, timerExpire, PendingIntent.FLAG_CANCEL_CURRENT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { am.setAlarmClock(new AlarmManager.AlarmClockInfo(wakeUpTime, sender), sender); } else { am.set(AlarmManager.RTC_WAKEUP, wakeUpTime, sender); } */ Log.e("TAG", "4 bitince servisi durduracak, broadcast"); Intent notificationIntent = new Intent(this, MainActivity.class); notificationIntent.setAction(Constants.ACTION.MAIN_ACTION); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); notificationIntent.putExtra("yeni", "yeni"); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); Log.e("TAG", "5 tklarsam ekran a"); Bitmap icon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher); Notification notification = new NotificationCompat.Builder(this).setContentTitle("Snav Devam Ediyor") .setTicker("Snav Devam Ediyor").setContentText("Snav Devam Ediyor") .setSmallIcon(R.mipmap.ic_launcher) .setLargeIcon(Bitmap.createScaledBitmap(icon, 128, 128, false)).setContentIntent(pendingIntent) .setOngoing(true).build(); startForeground(Constants.NOTIFICATION_ID.FOREGROUND_SERVICE, notification); Log.e("TAG", "6 Devam ediyor"); } else if (intent.getAction().equals(Constants.ACTION.STOPFOREGROUND_ACTION)) { Log.i(LOG_TAG, "Received Stop Foreground Intent"); Intent cancelIntent = new Intent(this, TimerExpiredReceiver.class); PendingIntent sender = PendingIntent.getBroadcast(this, 0, cancelIntent, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); am.cancel(sender); Log.e("TAG", "9 Receiver pta"); stopForeground(true); stopSelf(); Log.e("TAG", "10 Notif ptal"); } return START_REDELIVER_INTENT; }