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.google.samples.apps.iosched.ui.debug.actions.ShowSessionNotificationDebugAction.java
@Override public void run(Context context, Callback callback) { Intent i = new Intent(Intent.ACTION_VIEW, ScheduleContract.Sessions.buildSessionUri("__keynote__")); PendingIntent pi = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); Intent mapIntent = new Intent(context, UIUtils.getMapActivityClass(context)); mapIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME); mapIntent.putExtra(BaseMapActivity.EXTRA_ROOM, "keynote"); PendingIntent piMap = TaskStackBuilder.create(context).addNextIntent(mapIntent).getPendingIntent(0, PendingIntent.FLAG_CANCEL_CURRENT); //= PendingIntent.getActivity(context, 0, mapIntent, 0); NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context) .setContentTitle("test notification").setContentText("yep, this is a test") .setTicker("hey, you got a test") .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE) .setSmallIcon(R.drawable.ic_stat_notification).setContentIntent(pi) .setPriority(Notification.PRIORITY_MAX).setAutoCancel(true); notifBuilder.addAction(R.drawable.ic_map_holo_dark, context.getString(R.string.title_map), piMap); NotificationCompat.InboxStyle richNotification = new NotificationCompat.InboxStyle(notifBuilder) .setBigContentTitle(//from w w w . j a v a2 s.c o m context.getResources().getQuantityString(R.plurals.session_notification_title, 1, 8, 1)); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(32534, richNotification.build()); }
From source file:mchs.neverforget.services.NotificationIntentService.java
public static void startCustomRecurrentNotificationAlarm(Context context, int customId) { //Toast.makeText(context, "startCustomRecurrentNotificationAlarm"+customId, Toast.LENGTH_SHORT).show(); Intent intent = new Intent(context, NotificationIntentService.class); if (customId == 1) { intent.setAction(ACTION_NOTIFY_CUSTOM1); } else if (customId == 2) { intent.setAction(ACTION_NOTIFY_CUSTOM2); } else if (customId == 3) { intent.setAction(ACTION_NOTIFY_CUSTOM3); }//from w w w. j a va2 s . co m PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager alarmManager = (AlarmManager) context.getSystemService(ALARM_SERVICE); String[] hourOfDay = PreferenceManager.getDefaultSharedPreferences(context) .getString("notification_time_picker" + customId, "12:00").split(":"); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(hourOfDay[0])); calendar.set(Calendar.MINUTE, Integer.parseInt(hourOfDay[1])); if (calendar.getTimeInMillis() < System.currentTimeMillis()) { calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + 1); } alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pendingIntent); }
From source file:net.bither.util.SystemUtil.java
public static void nmNotifyOfWallet(NotificationManager nm, Context context, int notifyId, Intent intent, String title, String contentText, int iconId, int rawId) { final NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setSmallIcon(iconId);// w w w .j ava2 s . co m builder.setContentText(contentText); builder.setContentTitle(title); builder.setContentIntent(PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT)); builder.setWhen(System.currentTimeMillis()); Notification notification = null; if (ServiceUtil.isNoPrompt(System.currentTimeMillis())) { notification = builder.build(); notification.flags = Notification.FLAG_AUTO_CANCEL | Notification.FLAG_ONLY_ALERT_ONCE; notification.sound = null; } else { builder.setSound(Uri.parse("android.resource://" + context.getPackageName() + "/" + rawId)); notification = builder.build(); notification.flags = Notification.FLAG_AUTO_CANCEL | Notification.FLAG_ONLY_ALERT_ONCE; notification.flags |= Notification.FLAG_SHOW_LIGHTS; notification.ledARGB = 0xFF84E4FA; notification.ledOnMS = 3000; notification.ledOffMS = 2000; } nm.notify(notifyId, notification); }
From source file:com.example.leonid.chatzilla.Chat.NotificationMaker.java
@Override public Object doTask() { final Intent notificationIntent = new Intent(mContext, MainActivity.class); notificationIntent.putExtra("phoneNum", mPhone); notificationIntent.putExtra("friendName", mTitle); final int iUniqueId = (int) (System.currentTimeMillis() & 0xfffffff); final PendingIntent contentIntent = PendingIntent.getActivity(mContext, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); final NotificationManager notificationManager = (NotificationManager) mContext .getSystemService(Context.NOTIFICATION_SERVICE); final NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext); builder.setContentIntent(contentIntent).setSmallIcon(R.drawable.warrning).setContentTitle(mTitle) .setContentText(mMessage).setAutoCancel(true); notificationManager.notify(iUniqueId, builder.build()); return null;//w w w . j a va 2 s . c o m }
From source file:at.wada811.dayscounter.view.activity.SettingsActivity.java
public static PendingIntent createPendingIntent(Context context, int appWidgetId) { Intent intent = new Intent(context, SettingsActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); return PendingIntent.getActivity(context, appWidgetId, intent, PendingIntent.FLAG_CANCEL_CURRENT); }
From source file:net.frakbot.fweather.WearService.java
private static PendingIntent createAppPendingIntent(Context context) { Intent notificationIntent = createAppIntent(context); return PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); }
From source file:com.devnoobs.bmr.Powiadomienia.java
public void setAlarm(int h, int m) { Calendar calendar = przygotujCzas(h, m); AlarmManager am = (AlarmManager) c.getSystemService(Context.ALARM_SERVICE); Intent i = new Intent(S); PendingIntent pi = PendingIntent.getBroadcast(c, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); IntentFilter intentFilter = new IntentFilter(S); Powiadomienia p = new Powiadomienia(); c.registerReceiver(p, intentFilter); am.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), 1000 * 60 * 10, pi); // Millisec * Sec * Min //am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), AlarmManager.INTERVAL_DAY, pi); // showToast("Powiadomienie wlaczone"); }
From source file:com.eeec.GestionEspresso.gcm.KGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*from w w w . ja v a2s. c o m*/ */ private void sendNotification(String message) { Intent intent = new Intent(this, SplashActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_notification).setColor(getResources().getColor(R.color.colorPrimary)) .setContentText(message).setContentTitle("Gestin Espresso").setAutoCancel(true) .setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0, notificationBuilder.build()); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.InviteToWebSessionObj.java
public void handleDirectMessage(Context context, Contact from, JSONObject obj) { String arg = obj.optString(ARG); Intent launch = new Intent(); launch.setAction(Intent.ACTION_MAIN); launch.addCategory(Intent.CATEGORY_LAUNCHER); launch.putExtra("android.intent.extra.APPLICATION_ARGUMENT", arg); launch.putExtra("creator", false); launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); String webUrl = obj.optString(WEB_URL); launch.setData(Uri.parse(webUrl));// w w w. j av a2s. c o m PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launch, PendingIntent.FLAG_CANCEL_CURRENT); (new PresenceAwareNotify(context)).notify("New Invitation", "Invitation received", "Click to launch application.", contentIntent); }
From source file:org.nerdcircus.android.klaxon.Notifier.java
@Override public void onReceive(Context context, Intent intent) { NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); AlarmManager am = (AlarmManager) context.getSystemService(Activity.ALARM_SERVICE); if (intent.getAction().equals(Pager.PAGE_RECEIVED)) { Log.d(TAG, "new page received. notifying."); //get subject line of page, for notification. Cursor cursor = context.getContentResolver().query(intent.getData(), new String[] { Pager.Pages._ID, Pager.Pages.SUBJECT }, null, null, null); cursor.moveToFirst();// w ww . java2s. com String page_subj = cursor.getString(cursor.getColumnIndex(Pager.Pages.SUBJECT)); Notification n = getNotification(context, page_subj); n.sound = null; //no noise initially. wait for the delayed ANNOY action below. nm.notify(R.string.notify_page, n); Intent i = new Intent(Pager.ANNOY_ACTION); //we cant use data here, because it makes the silencing fail. i.putExtra("notification_text", page_subj); PendingIntent annoyintent = PendingIntent.getBroadcast(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); Log.d(TAG, "notifcation interval: " + prefs.getString("notification_interval", "unknown")); long repeat_interval_ms = Integer.valueOf(prefs.getString("notification_interval", "20000")) .longValue(); Log.d(TAG, "notifcation interval: " + repeat_interval_ms); // 500 ms delay, to prevent the regular text message noise from stomping on us. am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 500, repeat_interval_ms, annoyintent); } else if (intent.getAction().equals(Pager.SILENCE_ACTION)) { Log.d(TAG, "cancelling the notification..."); Intent i = new Intent(Pager.ANNOY_ACTION); PendingIntent annoyintent = PendingIntent.getBroadcast(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); am.cancel(annoyintent); nm.cancel(R.string.notify_page); } else if (intent.getAction().equals(Pager.ANNOY_ACTION)) { Log.e(TAG, "got annoy intent. annoying."); //just be annoying. Notification n = getNotification(context, intent.getStringExtra("notification_text")); nm.notify(R.string.notify_page, n); } else if (intent.getAction().equals("org.nerdcircus.android.klaxon.REPLY_SENT")) { //a reply was sent. update state in the db. if (Activity.RESULT_OK == getResultCode()) { Log.d(TAG, "reply successful. updating ack status.."); //result was sent. update state. updateAckStatus(context, intent.getData(), intent.getIntExtra(Pager.EXTRA_NEW_ACK_STATUS, 0)); } else { Log.e(TAG, "reply failed!!! doing nothing."); } } else { Log.e(TAG, "Uncaught Action:" + intent.getAction()); } }