List of usage examples for android.support.v4.app NotificationManagerCompat cancelAll
public void cancelAll()
From source file:Main.java
public static void cancelAll(Context context) { NotificationManagerCompat nm = NotificationManagerCompat.from(context); nm.cancelAll(); }
From source file:com.bobomee.android.common.util.NotificationUtil.java
/** * ?// w w w . ja v a 2 s .com */ public static void clearAllNotify(NotificationManagerCompat mNotificationManager) { mNotificationManager.cancelAll();// ? }
From source file:com.onefishtwo.bbqtimer.Notifier.java
/** Cancels all of this app's notifications. */ public void cancelAll() { NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context); notificationManager.cancelAll(); }
From source file:com.android.mail.utils.NotificationUtils.java
/** * Get all notifications for all accounts and cancel them. **//*from w w w. j av a 2 s . c o m*/ public static void cancelAllNotifications(Context context) { LogUtils.d(LOG_TAG, "cancelAllNotifications - cancelling all"); NotificationManagerCompat nm = NotificationManagerCompat.from(context); nm.cancelAll(); clearAllNotfications(context); }
From source file:com.android.mail.utils.NotificationUtils.java
/** * Get all notifications for all accounts, optionally cancel them, and repost. * This happens when locale changes. If you only want to resend messages from one * account-folder pair, pass in the account and folder that should be resent. * All other account-folder pairs will not have their notifications resent. * All notifications will be resent if account or folder is null. * * @param context Current context./*from w w w . ja va 2 s. c o m*/ * @param cancelExisting True, if all notifications should be canceled before resending. * False, otherwise. * @param accountUri The {@link Uri} of the {@link Account} of the notification * upon which an action occurred, or {@code null}. * @param folderUri The {@link Uri} of the {@link Folder} of the notification * upon which an action occurred, or {@code null}. */ public static void resendNotifications(Context context, final boolean cancelExisting, final Uri accountUri, final FolderUri folderUri, final ContactFetcher contactFetcher) { LogUtils.i(LOG_TAG, "resendNotifications cancelExisting: %b, account: %s, folder: %s", cancelExisting, accountUri == null ? null : LogUtils.sanitizeName(LOG_TAG, accountUri.toString()), folderUri == null ? null : LogUtils.sanitizeName(LOG_TAG, folderUri.toString())); if (cancelExisting) { LogUtils.d(LOG_TAG, "resendNotifications - cancelling all"); NotificationManagerCompat nm = NotificationManagerCompat.from(context); nm.cancelAll(); } // Re-validate the notifications. final NotificationMap notificationMap = getNotificationMap(context); final Set<NotificationKey> keys = notificationMap.keySet(); for (NotificationKey notification : keys) { final Folder folder = notification.folder; final int notificationId = getNotificationId(notification.account.getAccountManagerAccount(), folder); // Only resend notifications if the notifications are from the same folder // and same account as the undo notification that was previously displayed. if (accountUri != null && !Objects.equal(accountUri, notification.account.uri) && folderUri != null && !Objects.equal(folderUri, folder.folderUri)) { LogUtils.d(LOG_TAG, "resendNotifications - not resending %s / %s" + " because it doesn't match %s / %s", notification.account.uri, folder.folderUri, accountUri, folderUri); continue; } LogUtils.d(LOG_TAG, "resendNotifications - resending %s / %s", notification.account.uri, folder.folderUri); final NotificationAction undoableAction = NotificationActionUtils.sUndoNotifications .get(notificationId); if (undoableAction == null) { validateNotifications(context, folder, notification.account, true, false, notification, contactFetcher); } else { // Create an undo notification NotificationActionUtils.createUndoNotification(context, undoableAction); } } }
From source file:com.tct.mail.utils.NotificationUtils.java
/** * Get all notifications for all accounts, optionally cancel them, and repost. * This happens when locale changes. If you only want to resend messages from one * account-folder pair, pass in the account and folder that should be resent. * All other account-folder pairs will not have their notifications resent. * All notifications will be resent if account or folder is null. * * @param context Current context./* w ww .j a va 2 s . co m*/ * @param cancelExisting True, if all notifications should be canceled before resending. * False, otherwise. * @param accountUri The {@link Uri} of the {@link Account} of the notification * upon which an action occurred. * @param folderUri The {@link Uri} of the {@link Folder} of the notification * upon which an action occurred. */ public static void resendNotifications(Context context, final boolean cancelExisting, final Uri accountUri, final FolderUri folderUri, final ContactPhotoFetcher photoFetcher) { //M upgrade: Bug: 17713589 Gmail crashes when accessing an old notification for an account that has been deleted. LogUtils.i(LOG_TAG, "resendNotifications cancelExisting: %b, account: %s, folder: %s", cancelExisting, accountUri == null ? null : LogUtils.sanitizeName(LOG_TAG, accountUri.toString()), folderUri == null ? null : LogUtils.sanitizeName(LOG_TAG, folderUri.toString())); if (cancelExisting) { LogUtils.d(LOG_TAG, "resendNotifications - cancelling all"); NotificationManagerCompat nm = NotificationManagerCompat.from(context); nm.cancelAll(); } // Re-validate the notifications. final NotificationMap notificationMap = getNotificationMap(context); final Set<NotificationKey> keys = notificationMap.keySet(); for (NotificationKey notification : keys) { final Folder folder = notification.folder; final int notificationId = getNotificationId(notification.account.getAccountManagerAccount(), folder); // Only resend notifications if the notifications are from the same folder // and same account as the undo notification that was previously displayed. if (accountUri != null && !Objects.equal(accountUri, notification.account.uri) && folderUri != null && !Objects.equal(folderUri, folder.folderUri)) { LogUtils.d(LOG_TAG, "resendNotifications - not resending %s / %s" + " because it doesn't match %s / %s", notification.account.uri, folder.folderUri, accountUri, folderUri); continue; } LogUtils.d(LOG_TAG, "resendNotifications - resending %s / %s", notification.account.uri, folder.folderUri); final NotificationAction undoableAction = NotificationActionUtils.sUndoNotifications .get(notificationId); if (undoableAction == null) { validateNotifications(context, folder, notification.account, true, false, notification, photoFetcher); } else { // Create an undo notification NotificationActionUtils.createUndoNotification(context, undoableAction); } } }