List of usage examples for android.app PendingIntent cancel
public void cancel()
From source file:org.ohmage.reminders.types.location.LocTrigService.java
private void setKeepAliveAlarm(Context context) { Intent i = new Intent(ACTION_ALRM_SRV_KEEP_ALIVE).setPackage(context.getPackageName()); //set the alarm if not already existing PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, PendingIntent.FLAG_NO_CREATE); AlarmManager alarmMan = (AlarmManager) getSystemService(ALARM_SERVICE); if (pi != null) { alarmMan.cancel(pi);/* w ww .ja v a 2 s . co m*/ pi.cancel(); } pi = PendingIntent.getBroadcast(this, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); alarmMan.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + SERV_KEEP_ALIVE_TIME, SERV_KEEP_ALIVE_TIME, pi); }
From source file:org.ohmage.triggers.types.location.LocTrigService.java
private void setKeepAliveAlarm() { Intent i = new Intent(ACTION_ALRM_SRV_KEEP_ALIVE); //set the alarm if not already existing PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, PendingIntent.FLAG_NO_CREATE); AlarmManager alarmMan = (AlarmManager) getSystemService(ALARM_SERVICE); if (pi != null) { alarmMan.cancel(pi);// w w w . j a v a2 s . c o m pi.cancel(); } pi = PendingIntent.getBroadcast(this, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); alarmMan.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + SERV_KEEP_ALIVE_TIME, SERV_KEEP_ALIVE_TIME, pi); }
From source file:org.ohmage.reminders.types.location.LocTrigService.java
private void cancelTriggerAlwaysAlarm(int trigId) { Intent i = createTriggerAlwaysAlarmIntent(trigId); PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, PendingIntent.FLAG_NO_CREATE); if (pi != null) { //cancel the alarm AlarmManager alarmMan = (AlarmManager) getSystemService(ALARM_SERVICE); alarmMan.cancel(pi);/*from www . j a v a 2s . c o m*/ pi.cancel(); } }
From source file:com.updetector.MainActivity.java
/** * Respond to "Stop" button by canceling updates. * @param view The view that triggered this method. *//* w w w. j a v a 2s . c om*/ public void stopGoogleActivityRecognitionUpdates(View view) { // Check for Google Play services if (!isGooglePlayServiceAvailable()) { return; } /* * Set the request type. If a connection error occurs, and Google Play services can * handle it, then onActivityResult will use the request type to retry the request */ mRequestType = Constants.REQUEST_TYPE.REMOVE; // Pass the remove request to the remover object mGoogleActivityDetectionRemover.removeUpdates(mGoogleActivityDetectionRequester.getRequestPendingIntent()); /* * Cancel the PendingIntent. Even if the removal request fails, canceling the PendingIntent * will stop the updates. */ PendingIntent pIntent = mGoogleActivityDetectionRequester.getRequestPendingIntent(); if (pIntent != null) pIntent.cancel(); }