List of usage examples for android.app NotificationManager cancel
public void cancel(int id)
From source file:com.android.calendarDemo.alerts.DismissAlarmsService.java
@Override public void onHandleIntent(Intent intent) { long eventId = intent.getLongExtra(AlertUtils.EVENT_ID_KEY, -1); long eventStart = intent.getLongExtra(AlertUtils.EVENT_START_KEY, -1); long eventEnd = intent.getLongExtra(AlertUtils.EVENT_END_KEY, -1); boolean showEvent = intent.getBooleanExtra(AlertUtils.SHOW_EVENT_KEY, false); long[] eventIds = intent.getLongArrayExtra(AlertUtils.EVENT_IDS_KEY); int notificationId = intent.getIntExtra(AlertUtils.NOTIFICATION_ID_KEY, -1); Uri uri = CalendarAlerts.CONTENT_URI; String selection;/*from w w w.j a va 2s .c o m*/ // Dismiss a specific fired alarm if id is present, otherwise, dismiss all alarms if (eventId != -1) { selection = CalendarAlerts.STATE + "=" + CalendarAlerts.STATE_FIRED + " AND " + CalendarAlerts.EVENT_ID + "=" + eventId; } else if (eventIds != null && eventIds.length > 0) { selection = buildMultipleEventsQuery(eventIds); } else { selection = CalendarAlerts.STATE + "=" + CalendarAlerts.STATE_FIRED; } ContentResolver resolver = getContentResolver(); ContentValues values = new ContentValues(); values.put(PROJECTION[COLUMN_INDEX_STATE], CalendarAlerts.STATE_DISMISSED); resolver.update(uri, values, selection, null); // Remove from notification bar. if (notificationId != -1) { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(notificationId); } if (showEvent) { // Show event on Calendar app by building an intent and task stack to start // EventInfoActivity with AllInOneActivity as the parent activity rooted to home. Intent i = AlertUtils.buildEventViewIntent(this, eventId, eventStart, eventEnd); TaskStackBuilder.create(this).addParentStack(EventInfoActivity.class).addNextIntent(i) .startActivities(); } // Stop this service stopSelf(); }
From source file:com.google.android.gms.nearby.messages.samples.hellobeacons.BackgroundSubscribeIntentService.java
private void removeNotification() { NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.cancel(MESSAGES_NOTIFICATION_ID); }
From source file:org.mozilla.gecko.fxa.sync.FxAccountNotificationManager.java
/** * Remove all Firefox Account related notifications from the notification manager. * * @param context/*from w w w . j a v a 2 s . c o m*/ * Android context. */ public void clear(Context context) { final NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(notificationId); }
From source file:pandroid.agent.PandroidAgentListener.java
public static void CancelNotification(Context ctx, int notifyId) { String ns = Context.NOTIFICATION_SERVICE; NotificationManager nMgr = (NotificationManager) ctx.getSystemService(ns); nMgr.cancel(notifyId); }
From source file:com.klinker.android.twitter.activities.compose.NotificationCompose.java
@Override public void setUpReplyText() { // mark the messages as read here NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(1); mNotificationManager.cancel(9);//from w w w . j av a 2 s . c om sharedPrefs = getSharedPreferences("com.klinker.android.twitter_world_preferences", 0); Context context = getApplicationContext(); int currentAccount = sharedPrefs.getInt("current_account", 1); // we can just mark everything as read because it isnt taxing at all and won't do anything in the mentions if there isn't one // and the shared prefs are easy. // this is only called from the notification and there will only ever be one thing that is unread when this button is available MentionsDataSource.getInstance(context).markAllRead(currentAccount); // set up the reply box sharedPrefs.edit().putInt("dm_unread_" + currentAccount, 0).commit(); reply.setText(sharedPrefs.getString("from_notification", "")); reply.setSelection(reply.getText().toString().length()); notiId = sharedPrefs.getLong("from_notification_long", 0); replyText = sharedPrefs.getString("from_notification_text", ""); sharedPrefs.edit().putLong("from_notification_id", 0).commit(); sharedPrefs.edit().putString("from_notification_text", "").commit(); sharedPrefs.edit().putString("from_notification", "").commit(); sharedPrefs.edit().putBoolean("from_notification_bool", false).commit(); String t = reply.getText().toString(); if (!android.text.TextUtils.isEmpty(t) && !t.endsWith(" ")) { reply.append(" "); reply.setSelection(reply.getText().length()); } // try from android wear device CharSequence voiceReply = getVoiceReply(getIntent()); if (voiceReply != null) { if (!voiceReply.equals("")) { // set the text reply.append(voiceReply); // send the message doneClick(); finish(); } } }
From source file:com.klinker.android.twitter.ui.compose.NotificationCompose.java
@Override public void setUpReplyText() { // mark the messages as read here NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(1); mNotificationManager.cancel(9);/* w ww. ja v a 2 s. com*/ sharedPrefs = getSharedPreferences("com.klinker.android.twitter_world_preferences", Context.MODE_WORLD_READABLE + Context.MODE_WORLD_WRITEABLE); Context context = getApplicationContext(); int currentAccount = sharedPrefs.getInt("current_account", 1); // we can just mark everything as read because it isnt taxing at all and won't do anything in the mentions if there isn't one // and the shared prefs are easy. // this is only called from the notification and there will only ever be one thing that is unread when this button is available MentionsDataSource.getInstance(context).markAllRead(currentAccount); // set up the reply box sharedPrefs.edit().putInt("dm_unread_" + currentAccount, 0).commit(); reply.setText(sharedPrefs.getString("from_notification", "")); reply.setSelection(reply.getText().toString().length()); notiId = sharedPrefs.getLong("from_notification_long", 0); replyText = sharedPrefs.getString("from_notification_text", ""); sharedPrefs.edit().putLong("from_notification_id", 0).commit(); sharedPrefs.edit().putString("from_notification_text", "").commit(); sharedPrefs.edit().putString("from_notification", "").commit(); sharedPrefs.edit().putBoolean("from_notification_bool", false).commit(); String t = reply.getText().toString(); if (!android.text.TextUtils.isEmpty(t) && !t.endsWith(" ")) { reply.append(" "); reply.setSelection(reply.getText().length()); } // try from android wear device CharSequence voiceReply = getVoiceReply(getIntent()); if (voiceReply != null) { if (!voiceReply.equals("")) { // set the text reply.append(voiceReply); // send the message doneClick(); finish(); } } }
From source file:com.mutu.gpstracker.streaming.CustomUpload.java
private void clearNotification(Context context) { String ns = Context.NOTIFICATION_SERVICE; NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns); mNotificationManager.cancel(NOTIFICATION_ID); }
From source file:edu.umich.eecs.rtcl.lp_doctor.ui.NotificationControl.java
public void cancelNotification() { Util.Log(Util.SESSION_TAG, "cancel notification"); NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.cancel(notID); }
From source file:com.android.calendar.alerts.DismissAlarmsService.java
@Override public void onHandleIntent(Intent intent) { long eventId = intent.getLongExtra(AlertUtils.EVENT_ID_KEY, -1); long eventStart = intent.getLongExtra(AlertUtils.EVENT_START_KEY, -1); long eventEnd = intent.getLongExtra(AlertUtils.EVENT_END_KEY, -1); boolean showEvent = intent.getBooleanExtra(AlertUtils.SHOW_EVENT_KEY, false); long[] eventIds = intent.getLongArrayExtra(AlertUtils.EVENT_IDS_KEY); long[] eventStarts = intent.getLongArrayExtra(AlertUtils.EVENT_STARTS_KEY); int notificationId = intent.getIntExtra(AlertUtils.NOTIFICATION_ID_KEY, -1); List<AlarmId> alarmIds = new LinkedList<AlarmId>(); Uri uri = CalendarAlerts.CONTENT_URI; String selection;/* w w w.j a v a 2 s.c o m*/ // Dismiss a specific fired alarm if id is present, otherwise, dismiss all alarms if (eventId != -1) { alarmIds.add(new AlarmId(eventId, eventStart)); selection = CalendarAlerts.STATE + "=" + CalendarAlerts.STATE_FIRED + " AND " + CalendarAlerts.EVENT_ID + "=" + eventId; } else if (eventIds != null && eventIds.length > 0 && eventStarts != null && eventIds.length == eventStarts.length) { selection = buildMultipleEventsQuery(eventIds); for (int i = 0; i < eventIds.length; i++) { alarmIds.add(new AlarmId(eventIds[i], eventStarts[i])); } } else { // NOTE: I don't believe that this ever happens. selection = CalendarAlerts.STATE + "=" + CalendarAlerts.STATE_FIRED; } GlobalDismissManager.dismissGlobally(getApplicationContext(), alarmIds); ContentResolver resolver = getContentResolver(); ContentValues values = new ContentValues(); values.put(PROJECTION[COLUMN_INDEX_STATE], CalendarAlerts.STATE_DISMISSED); resolver.update(uri, values, selection, null); // Remove from notification bar. if (notificationId != -1) { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(notificationId); } if (showEvent) { // Show event on Calendar app by building an intent and task stack to start // EventInfoActivity with AllInOneActivity as the parent activity rooted to home. Intent i = AlertUtils.buildEventViewIntent(this, eventId, eventStart, eventEnd); TaskStackBuilder.create(this).addParentStack(EventInfoActivity.class).addNextIntent(i) .startActivities(); } }
From source file:net.jongrakko.zipsuri.gcm.ZipsuriGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*from w w w . java2 s . c o m*/ */ private void sendNotification(String title, String userId, String message, String type, String id) { Intent intent = new Intent(this, IntroActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(INTENT_TYPE, type); intent.putExtra(INTENT_ID, id); PendingIntent pendingIntent = PendingIntent.getActivity(this, 7050, intent, PendingIntent.FLAG_UPDATE_CURRENT); String content; if (type.equals(TYPE_NEW_ANSWER) || type.equals(TYPE_NEW_QUESTION)) { if (message == null) { message = "()"; } content = userId + " : " + message; } else { content = message; } Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_name).setContentTitle(title).setContentText(content) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.cancel(7050); notificationManager.notify(7050, notificationBuilder.build()); Intent dialogIntent = new Intent(this, PushDialog.class); dialogIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); dialogIntent.putExtra(INTENT_TYPE, type); dialogIntent.putExtra(INTENT_ID, id); dialogIntent.putExtra(PushDialog.INTENT_CONTENT, content); dialogIntent.putExtra(PushDialog.INTENT_TITLE, title); startActivity(dialogIntent); }