List of usage examples for android.app PendingIntent FLAG_CANCEL_CURRENT
int FLAG_CANCEL_CURRENT
To view the source code for android.app PendingIntent FLAG_CANCEL_CURRENT.
Click Source Link
From source file:com.razza.apps.iosched.service.SessionAlarmService.java
public void scheduleFeedbackAlarm(final long sessionEnd, final long alarmOffset, final String sessionTitle) { // By default, feedback alarms fire 5 minutes before session end time. If alarm offset is // provided, alarm is set to go off that much time from now (useful for testing). long alarmTime; if (alarmOffset == UNDEFINED_ALARM_OFFSET) { alarmTime = sessionEnd - MILLI_FIVE_MINUTES; } else {// www . j av a 2 s . co m alarmTime = UIUtils.getCurrentTime(this) + alarmOffset; } LogUtils.LOGD(TAG, "Scheduling session feedback alarm for session '" + sessionTitle + "'"); LogUtils.LOGD(TAG, " -> end time: " + sessionEnd + " = " + (new Date(sessionEnd)).toString()); LogUtils.LOGD(TAG, " -> alarm time: " + alarmTime + " = " + (new Date(alarmTime)).toString()); final Intent feedbackIntent = new Intent(ACTION_NOTIFY_SESSION_FEEDBACK, null, this, SessionAlarmService.class); PendingIntent pi = PendingIntent.getService(this, 1, feedbackIntent, PendingIntent.FLAG_CANCEL_CURRENT); final AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, alarmTime, pi); }
From source file:com.google.samples.apps.iosched.service.SessionAlarmService.java
public void scheduleFeedbackAlarm(final long sessionEnd, final long alarmOffset, final String sessionTitle) { // By default, feedback alarms fire 5 minutes before session end time. If alarm offset is // provided, alarm is set to go off that much time from now (useful for testing). long alarmTime; if (alarmOffset == UNDEFINED_ALARM_OFFSET) { alarmTime = sessionEnd - MILLI_FIVE_MINUTES; } else {/*from www.j ava 2 s.com*/ alarmTime = UIUtils.getCurrentTime(this) + alarmOffset; } LOGD(TAG, "Scheduling session feedback alarm for session '" + sessionTitle + "'"); LOGD(TAG, " -> end time: " + sessionEnd + " = " + (new Date(sessionEnd)).toString()); LOGD(TAG, " -> alarm time: " + alarmTime + " = " + (new Date(alarmTime)).toString()); final Intent feedbackIntent = new Intent(ACTION_NOTIFY_SESSION_FEEDBACK, null, this, SessionAlarmService.class); PendingIntent pi = PendingIntent.getService(this, 1, feedbackIntent, PendingIntent.FLAG_CANCEL_CURRENT); final AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, alarmTime, pi); }
From source file:at.jclehner.rxdroid.NotificationReceiver.java
private PendingIntent createDrugListIntent(Date date) { final Intent intent = new Intent(mContext, DrugListActivity.class); intent.putExtra(DrugListActivity.EXTRA_STARTED_FROM_NOTIFICATION, true); intent.putExtra(DrugListActivity.EXTRA_DATE, date); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); return PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); }
From source file:mobisocial.musubi.identity.AphidIdentityProvider.java
private void sendNotification(String account) { Intent launch = new Intent(mContext, SettingsActivity.class); launch.putExtra(SettingsActivity.ACTION, SettingsActivity.SettingsAction.ACCOUNT.toString()); PendingIntent contentIntent = PendingIntent.getActivity(mContext, 0, launch, PendingIntent.FLAG_CANCEL_CURRENT); (new PresenceAwareNotify(mContext)).notify(SIGNIN_TEXT, account + " account failed to connect", contentIntent);/* w w w . j a va 2 s.c om*/ }
From source file:com.radiofarda.istgah.MediaNotificationManager.java
private PendingIntent createContentIntent(MediaDescriptionCompat description) { Intent openUI = new Intent(mService, PodcastsActivity.class); openUI.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); openUI.putExtra(PodcastsActivity.EXTRA_START_FULLSCREEN, true); if (description != null) { openUI.putExtra(PodcastsActivity.EXTRA_CURRENT_MEDIA_DESCRIPTION, description); }/* www . j a va 2 s . co m*/ return PendingIntent.getActivity(mService, REQUEST_CODE, openUI, PendingIntent.FLAG_CANCEL_CURRENT); }
From source file:de.ub0r.android.websms.WebSMSReceiver.java
/** * Displays notification if sending failed * * @param context context//from w ww. jav a 2 s . c om * @param specs {@link de.ub0r.android.websms.connector.common.ConnectorSpec} * @param command {@link de.ub0r.android.websms.connector.common.ConnectorCommand} */ private static void displaySendingFailedNotification(final Context context, final ConnectorSpec specs, final ConnectorCommand command) { final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context); String to = Utils.joinRecipients(command.getRecipients(), ", "); final Intent i = new Intent(Intent.ACTION_SENDTO, Uri.parse(INTENT_SCHEME_SMSTO + ":" + Uri.encode(to)), context, WebSMS.class); // add pending intent i.putExtra(Intent.EXTRA_TEXT, command.getText()); i.putExtra(WebSMS.EXTRA_ERRORMESSAGE, specs.getErrorMessage()); i.setFlags(i.getFlags() | Intent.FLAG_ACTIVITY_NEW_TASK); final PendingIntent cIntent = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); NotificationCompat.Builder b = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.stat_notify_sms_failed) .setContentTitle(context.getString(R.string.notify_failed) + " " + specs.getErrorMessage()) .setContentText(to + ": " + command.getText()).setTicker(context.getString(R.string.notify_failed_)) .setWhen(System.currentTimeMillis()).setContentIntent(cIntent).setAutoCancel(true) .setLights(NOTIFICATION_LED_COLOR, NOTIFICATION_LED_ON, NOTIFICATION_LED_OFF); final String s = p.getString(WebSMS.PREFS_FAIL_SOUND, null); if (!TextUtils.isEmpty(s)) { b.setSound(Uri.parse(s)); } if (p.getBoolean(WebSMS.PREFS_FAIL_VIBRATE, false)) { b.setVibrate(VIBRATE_ON_FAIL_PATTERN); } NotificationManager mNotificationMgr = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationMgr.notify(getNotificationID(), b.build()); // show a toast as well final String em = specs.getErrorMessage(); if (em != null) { Toast.makeText(context, em, Toast.LENGTH_LONG).show(); } }
From source file:org.ohmage.reminders.notif.Notifier.java
private static void setAlarm(Context context, String action, int mins, Bundle extras) { Log.v(TAG, "Notifier: Setting alarm(" + mins + ", " + action + ")"); AlarmManager alarmMan = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(context, NotifReceiver.class).setAction(action); if (extras != null) { i.putExtras(extras);// w ww .ja v a 2 s. c o m } PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); long elapsed = mins * 60 * 1000; alarmMan.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + elapsed, pi); }
From source file:org.alfresco.mobile.android.platform.AlfrescoNotificationManager.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public int createNotification(int notificationId, Bundle params) { Notification notification;//from ww w. ja v a 2 s. c om // Get the builder to create notification. NotificationCompat.Builder builder = new NotificationCompat.Builder(appContext.getApplicationContext()); builder.setContentTitle(params.getString(ARGUMENT_TITLE)); if (params.containsKey(ARGUMENT_DESCRIPTION)) { builder.setContentText(params.getString(ARGUMENT_DESCRIPTION)); } builder.setNumber(0); if (AndroidVersion.isLollipopOrAbove()) { builder.setSmallIcon(R.drawable.ic_notification); builder.setColor(appContext.getResources().getColor(R.color.alfresco_sky)); } else { builder.setSmallIcon(R.drawable.ic_notification); } if (params.containsKey(ARGUMENT_DESCRIPTION)) { builder.setContentText(params.getString(ARGUMENT_DESCRIPTION)); } if (params.containsKey(ARGUMENT_CONTENT_INFO)) { builder.setContentInfo(params.getString(ARGUMENT_CONTENT_INFO)); } if (params.containsKey(ARGUMENT_SMALL_ICON)) { builder.setSmallIcon(params.getInt(ARGUMENT_SMALL_ICON)); } Intent i; PendingIntent pIntent; switch (notificationId) { case CHANNEL_SYNC: i = new Intent(PrivateIntent.ACTION_SYNCHRO_DISPLAY); pIntent = PendingIntent.getActivity(appContext, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); break; default: i = new Intent(PrivateIntent.ACTION_DISPLAY_OPERATIONS); i.putExtra(PrivateIntent.EXTRA_OPERATIONS_TYPE, notificationId); if (SessionUtils.getAccount(appContext) != null) { i.putExtra(PrivateIntent.EXTRA_ACCOUNT_ID, SessionUtils.getAccount(appContext).getId()); } pIntent = PendingIntent.getActivity(appContext, 0, i, 0); break; } builder.setContentIntent(pIntent); if (AndroidVersion.isICSOrAbove()) { if (params.containsKey(ARGUMENT_PROGRESS_MAX) && params.containsKey(ARGUMENT_PROGRESS)) { long max = params.getLong(ARGUMENT_PROGRESS_MAX); long progress = params.getLong(ARGUMENT_PROGRESS); float value = (((float) progress / ((float) max)) * 100); int percentage = Math.round(value); builder.setProgress(100, percentage, false); } if (params.getBoolean(ARGUMENT_INDETERMINATE)) { builder.setProgress(0, 0, true); } } else { RemoteViews remote = new RemoteViews(appContext.getPackageName(), R.layout.app_notification); remote.setImageViewResource(R.id.status_icon, R.drawable.ic_application_logo); remote.setTextViewText(R.id.status_text, params.getString(ARGUMENT_TITLE)); remote.setProgressBar(R.id.status_progress, params.getInt(ARGUMENT_PROGRESS_MAX), 0, false); builder.setContent(remote); } if (AndroidVersion.isJBOrAbove()) { builder.setPriority(0); notification = builder.build(); } else { notification = builder.getNotification(); } notification.flags |= Notification.FLAG_AUTO_CANCEL; ((NotificationManager) appContext.getSystemService(Context.NOTIFICATION_SERVICE)).notify(notificationId, notification); return notificationId; }
From source file:com.granita.tasks.notification.NotificationActionIntentService.java
private static PendingIntent getDelayActionIntent(Context context, int notificationId, Uri taskUri, long due, boolean delay1h, String timezone, boolean allday) { String action = null;/*w w w. jav a 2s .co m*/ if (delay1h) { action = ACTION_DELAY_1H; } else { action = ACTION_DELAY_1D; } final Intent intent = new Intent(action); intent.setPackage(context.getPackageName()); intent.setData(taskUri); intent.putExtra(EXTRA_TASK_DUE, due); intent.putExtra(EXTRA_TIMEZONE, timezone); intent.putExtra(EXTRA_ALLDAY, allday); intent.putExtra(EXTRA_NOTIFICATION_ID, notificationId); final PendingIntent pendingIntent = PendingIntent.getService(context, REQUEST_CODE_DELAY, intent, PendingIntent.FLAG_CANCEL_CURRENT); return pendingIntent; }
From source file:com.glanznig.beepme.BeeperApp.java
public void updateTimer(int status) { if (status != 3 || status != 4) { Intent intent = new Intent(this, BeepActivity.class); PendingIntent alarmIntent = PendingIntent.getActivity(this, ALARM_INTENT_ID, intent, PendingIntent.FLAG_CANCEL_CURRENT); alarmIntent.cancel();//from w w w . j a va2 s . co m } new ScheduledBeepTable(this.getApplicationContext()).updateStatus(getPreferences().getScheduledBeepId(), status); if (status != 3) { getPreferences().setScheduledBeepId(0L); } }