List of usage examples for android.app AlarmManager cancel
public void cancel(OnAlarmListener listener)
From source file:net.peterkuterna.android.apps.devoxxfrsched.service.CfpSyncManager.java
/** * Cancel a currently installed alarm./*from w w w . j ava 2 s. com*/ */ public void cancelSyncAlarm() { Log.d(TAG, "Cancelling sync alarm"); final Context context = getContext(); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); PendingIntent localPendingIntent = getAlarmPendingIntent(); am.cancel(localPendingIntent); }
From source file:townley.stuart.app.android.trekkinly.Notification_picker_class.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.notification_layout, container, false); final Button button = (Button) rootView.findViewById(R.id.Button); final Button button2 = (Button) rootView.findViewById(R.id.Button2); final Button button3 = (Button) rootView.findViewById(R.id.Button3); button.setOnClickListener(new View.OnClickListener() { @Override// w w w .j av a2 s . c o m public void onClick(View v) { showTimePickerDialog(v); AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f); animation1.setDuration(500); button.startAnimation(animation1); } }); button2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showDatePickerDialog(v); AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f); animation1.setDuration(500); button2.startAnimation(animation1); } }); button3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setNotification(); AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f); animation1.setDuration(500); button3.startAnimation(animation1); } }); button3.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { ComponentName receiver = new ComponentName(getActivity(), AlertClass.class); PackageManager pm = getActivity().getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); Intent intent = new Intent(getActivity(), AlertClass.class); AlarmManager alarmManager = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE); alarmManager.cancel(PendingIntent.getBroadcast(getActivity().getApplicationContext(), 1, intent, PendingIntent.FLAG_UPDATE_CURRENT)); Toast.makeText(getActivity(), "Notification reset!", Toast.LENGTH_SHORT).show(); AlphaAnimation animation1 = new AlphaAnimation(0.2f, 1.0f); animation1.setDuration(500); button3.startAnimation(animation1); //It would not let me assign void so I return true; } }); return rootView; }
From source file:com.hodor.company.areminder.service.TimerService.java
private void removeAlarm() { NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); notificationManager.cancel(1);/* w w w . j av a 2s .co m*/ AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(MainActivity.ACTION_SHOW_ALARM, null, this, TimerService.class); PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); alarmManager.cancel(pendingIntent); }
From source file:com.securecomcode.text.service.KeyCachingService.java
private void handleActivityStarted() { Log.w("KeyCachingService", "Incrementing activity count..."); AlarmManager alarmManager = (AlarmManager) this.getSystemService(ALARM_SERVICE); alarmManager.cancel(pending); activitiesRunning++;// w w w . j av a2 s. c om }
From source file:org.kegbot.app.service.CheckinService.java
private void unregisterAlarm() { if (mPendingIntent != null) { Log.d(TAG, "Unregistering alarm."); final AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); alarmManager.cancel(mPendingIntent); mPendingIntent = null;/*w w w . j av a2s. c o m*/ } }
From source file:com.sean.takeastand.storage.ScheduleEditor.java
private void cancelDailyRepeatingAlarm(int UID) { Intent intent = new Intent(mContext, StartScheduleReceiver.class); intent.putExtra(Constants.ALARM_UID, UID); PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, UID, intent, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); alarmManager.cancel(pendingIntent); Log.i(TAG, "Canceled a daily repeating alarm"); }
From source file:com.securecomcode.text.service.KeyCachingService.java
private void startTimeoutIfAppropriate() { boolean timeoutEnabled = TextSecurePreferences.isPassphraseTimeoutEnabled(this); if ((activitiesRunning == 0) && (this.masterSecret != null) && timeoutEnabled && !TextSecurePreferences.isPasswordDisabled(this)) { long timeoutMinutes = TextSecurePreferences.getPassphraseTimeoutInterval(this); long timeoutMillis = timeoutMinutes * 60 * 1000; Log.w("KeyCachingService", "Starting timeout: " + timeoutMillis); AlarmManager alarmManager = (AlarmManager) this.getSystemService(ALARM_SERVICE); alarmManager.cancel(pending); alarmManager.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + timeoutMillis, pending); }//w ww . j a va 2 s . c om }
From source file:no.ntnu.idi.socialhitchhiking.SocialHitchhikingApplication.java
public void killService() { AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); am.cancel(service); }
From source file:ca.zadrox.dota2esportticker.service.ReminderAlarmService.java
private void cancelAlarm(final long matchId, final long matchStart) { final long currentTime = TimeUtils.getUTCTime(); LOGD(TAG, "Unscheduling Alarm"); if (currentTime > matchStart) { LOGD(TAG, "wat."); return;/*w ww. jav a2 s .c om*/ } final Intent notifIntent = new Intent(ACTION_NOTIFY_MATCH, null, this, ReminderAlarmService.class); notifIntent.setData( new Uri.Builder().authority("ca.zadrox.dota2esportticker").path(String.valueOf(matchId)).build()); notifIntent.putExtra(ReminderAlarmService.EXTRA_MATCH_ID, matchId); notifIntent.putExtra(ReminderAlarmService.EXTRA_MATCH_START, matchStart); PendingIntent pi = PendingIntent.getService(this, 0, notifIntent, PendingIntent.FLAG_UPDATE_CURRENT); final AlarmManager am = (AlarmManager) getApplicationContext().getSystemService(Context.ALARM_SERVICE); am.cancel(pi); }
From source file:se.hyperlab.tigcm.TiGCMModule.java
@Kroll.method public void clearSchedule() { TiApplication app = TiApplication.getInstance(); int ntfCount = app.getAppProperties().getInt(PROPERTY_NOTIFICATION_COUNTER, 0); Log.d(TAG, "Clearing " + ntfCount + " notifications"); if (ntfCount > 0) { Intent intent = new Intent(app.getApplicationContext(), NotificationPublisher.class); for (int i = 0; i < ntfCount; i++) { PendingIntent pendingIntent = PendingIntent.getBroadcast(app.getApplicationContext(), i, intent, PendingIntent.FLAG_ONE_SHOT); AlarmManager alarmManager = (AlarmManager) app.getApplicationContext() .getSystemService(Context.ALARM_SERVICE); alarmManager.cancel(pendingIntent); pendingIntent.cancel();// w ww.j a va2 s . com } app.getAppProperties().setInt(PROPERTY_NOTIFICATION_COUNTER, 0); } }