List of usage examples for android.app NotificationManager cancel
public void cancel(int id)
From source file:org.smssecure.smssecure.notifications.MessageNotifier.java
private static void cancelOrphanedNotifications(@NonNull Context context, NotificationState notificationState) { if (Build.VERSION.SDK_INT >= 23) { try {//www. j a v a 2 s. com NotificationManager notifications = ServiceUtil.getNotificationManager(context); StatusBarNotification[] activeNotifications = notifications.getActiveNotifications(); for (StatusBarNotification notification : activeNotifications) { boolean validNotification = false; if (notification.getId() != SUMMARY_NOTIFICATION_ID) { for (NotificationItem item : notificationState.getNotifications()) { if (notification.getId() == (SUMMARY_NOTIFICATION_ID + item.getThreadId())) { validNotification = true; break; } } if (!validNotification) { notifications.cancel(notification.getId()); } } } } catch (Throwable e) { // XXX Android ROM Bug, see https://github.com/WhisperSystems/Signal-Android/issues/6043 Log.w(TAG, e); } } }
From source file:org.jraf.android.dcn.wearable.app.notif.NotificationWearableListenerService.java
private void dismissNotification() { Log.d();//from w w w . j a v a 2s. co m NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.cancel(NOTIFICATION_ID); }
From source file:ca.rmen.android.poetassistant.PoemAudioExport.java
private void cancelNotifications() { Log.v(TAG, "cancelNotifications"); NotificationManager notificationManager = (NotificationManager) mContext .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(EXPORT_PROGRESS_NOTIFICATION_ID); notificationManager.cancel(EXPORT_FINISH_NOTIFICATION_ID); }
From source file:com.google.fpl.gim.examplegame.ChoiceMoment.java
public void dismissNotification() { NotificationManager notificationManager = (NotificationManager) getMission().getService() .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(MainService.CHOICE_NOTIFICATION_ID); }
From source file:com.innoc.secureline.ui.RecentCallListActivity.java
@Override public void onResume() { super.onResume(); NotificationManager notificationManager = (NotificationManager) getActivity() .getSystemService(Activity.NOTIFICATION_SERVICE); notificationManager.cancel(DialerActivity.MISSED_CALL); }
From source file:edu.mit.mobile.android.locast.sync.LocastSimpleSyncService.java
private void clearNotification() { final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(R.id.locast_core__sync); }
From source file:com.cyanogenmod.settings.otgtoggle.UsbDeviceMonitorService.java
void updateNotification(boolean connected, int mode) { NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); if (!connected) { nm.cancel(OTG_NOTIFICATION_ID); return;// w w w .ja v a 2 s .c om } final Intent clickIntent = new Intent(this, OtgModeChooserActivity.class) .putExtra(OtgModeChooserActivity.EXTRA_CURRENT_MODE, getDetectionMode()); final PendingIntent clickPi = PendingIntent.getActivity(this, 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT); final int titleResId; switch (mode) { case MODE_HEADSET: titleResId = R.string.connection_notification_title_headset; break; case MODE_OTG: titleResId = R.string.connection_notification_title_otg; break; default: titleResId = R.string.connection_notification_title_detect; break; } final Notification.Builder builder = new Notification.Builder(this) .setSmallIcon(R.drawable.ic_headset_notification).setLocalOnly(true).setOngoing(true).setWhen(0) .setDefaults(0).setShowWhen(false).setCategory(Notification.CATEGORY_SERVICE) .setVisibility(Notification.VISIBILITY_PUBLIC).setPriority(Notification.PRIORITY_MIN) .setColor(getResources().getColor(com.android.internal.R.color.system_notification_accent_color)) .setContentTitle(getString(titleResId)) .setContentText(getString(R.string.connection_notification_text)).setContentIntent(clickPi); nm.notify(OTG_NOTIFICATION_ID, builder.build()); }
From source file:nu.yona.app.api.service.ActivityMonitorService.java
private void removeActivityMonitoringNotification() { NotificationManager mNotificationManager = (NotificationManager) this .getSystemService(NOTIFICATION_SERVICE); mNotificationManager.cancel(NOTIFICATION_ID); }
From source file:com.amaze.filemanager.asynchronous.asynctasks.DeleteTask.java
@Override public void onPostExecute(Boolean wasDeleted) { Intent intent = new Intent(MainActivity.KEY_INTENT_LOAD_LIST); String path = files.get(0).getParent(cd); intent.putExtra(MainActivity.KEY_INTENT_LOAD_LIST_FILE, path); cd.sendBroadcast(intent);// w w w .j a va2 s . co m if (!wasDeleted) { Toast.makeText(cd, cd.getResources().getString(R.string.error), Toast.LENGTH_SHORT).show(); } else if (compressedExplorerFragment == null) { Toast.makeText(cd, cd.getResources().getString(R.string.done), Toast.LENGTH_SHORT).show(); } if (compressedExplorerFragment != null) { compressedExplorerFragment.files.clear(); } // cancel any processing notification because of cut/paste operation NotificationManager notificationManager = (NotificationManager) cd .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(NotificationConstants.COPY_ID); }
From source file:com.mattermost.gcm.GcmMessageHandler.java
private void createNotification(boolean doAlert) { Context context = getBaseContext(); int defaults = 0; defaults = defaults | Notification.DEFAULT_LIGHTS | Notification.FLAG_AUTO_CANCEL; if (doAlert) { defaults = defaults | Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND; }/*from www . java 2 s . c om*/ Intent notificationIntent = new Intent(context, SplashScreenActivity.class); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent contentIndent = PendingIntent.getActivity(context, 0, notificationIntent, 0); PendingIntent deleteIntent = PendingIntent.getBroadcast(context, 0, new Intent(context, NotificationDismissReceiver.class), 0); NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); if (channelIdToNotification.size() == 0) { mNotificationManager.cancel(MESSAGE_NOTIFICATION_ID); return; } NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.mipmap.ic_launcher).setGroup(GROUP_KEY_MESSAGES).setDefaults(defaults) .setContentIntent(contentIndent).setDeleteIntent(deleteIntent).setAutoCancel(true); if (channelIdToNotification.size() == 1) { Bundle data = channelIdToNotification.entrySet().iterator().next().getValue(); String body = data.getString("message"); mBuilder.setContentTitle("Mattermost").setContentText(body) .setStyle(new NotificationCompat.BigTextStyle().bigText(body)); } else { NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle(); String summaryTitle = String.format("Mattermost (%d)", channelIdToNotification.size()); mBuilder.setContentTitle(summaryTitle); for (Bundle data : channelIdToNotification.values()) { style.addLine(data.getString("message")); } style.setBigContentTitle(summaryTitle); mBuilder.setStyle(style); } mNotificationManager.cancel(MESSAGE_NOTIFICATION_ID); mNotificationManager.notify(MESSAGE_NOTIFICATION_ID, mBuilder.build()); }