Example usage for android.app NotificationManager cancel

List of usage examples for android.app NotificationManager cancel

Introduction

In this page you can find the example usage for android.app NotificationManager cancel.

Prototype

public void cancel(int id) 

Source Link

Document

Cancel a previously shown notification.

Usage

From source file:net.ustyugov.jtalk.Notify.java

public static void cancelCallNotify(Context context) {
    NotificationManager mng = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    mng.cancel(NOTIFICATION_CALL);
}

From source file:com.andrewshu.android.reddit.common.Common.java

public static void cancelMailNotification(Context context) {
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancel(Constants.NOTIFICATION_HAVE_MAIL);
}

From source file:net.ustyugov.jtalk.Notify.java

public static void cancelNotify(Context context, String account, String jid) {
    String key = account + "/" + jid;
    if (!ids.containsKey(key))
        return;/*from w  w  w.j  a va  2 s .co m*/
    NotificationManager mng = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    mng.cancel(ids.get(key));
    ids.remove(key);
}

From source file:github.popeen.dsub.util.Notifications.java

public static void hideDownloadingNotification(final Context context, final DownloadService downloadService,
        Handler handler) {//from   w ww.j  ava2 s . co  m
    downloadShowing = false;
    if (playShowing) {
        NotificationManager notificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.cancel(NOTIFICATION_ID_DOWNLOADING);
    } else {
        downloadForeground = false;
        handler.post(new Runnable() {
            @Override
            public void run() {
                stopForeground(downloadService, true);
            }
        });
    }
}

From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.receiver.NotificationHelper.java

/**
 * Does not touch db/*from   w  w  w.  ja va 2s  . co m*/
 */
public static void cancelNotification(final Context context, final int notId) {
    final NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancel(notId);
}

From source file:com.keylesspalace.tusky.util.NotificationHelper.java

public static void clearNotificationsForActiveAccount(@NonNull Context context,
        @NonNull AccountManager accountManager) {
    AccountEntity account = accountManager.getActiveAccount();
    if (account != null) {
        account.setActiveNotifications("[]");
        accountManager.saveAccount(account);

        NotificationManager notificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        //noinspection ConstantConditions
        notificationManager.cancel((int) account.getId());
    }/*www  .  j  a  va 2s  .  c  om*/
}

From source file:github.popeen.dsub.util.Notifications.java

public static void hidePlayingNotification(final Context context, final DownloadService downloadService,
        Handler handler) {/*from   w w  w  .jav a2s.c om*/
    playShowing = false;

    // Remove notification and remove the service from the foreground
    handler.post(new Runnable() {
        @Override
        public void run() {
            stopForeground(downloadService, true);

            if (persistentPlayingShowing) {
                NotificationManager notificationManager = (NotificationManager) context
                        .getSystemService(Context.NOTIFICATION_SERVICE);
                notificationManager.cancel(NOTIFICATION_ID_PLAYING);
                persistentPlayingShowing = false;
            }
        }
    });

    // Get downloadNotification in foreground if playing
    if (downloadShowing) {
        showDownloadingNotification(context, downloadService, handler, downloadService.getCurrentDownloading(),
                downloadService.getBackgroundDownloads().size());
    }

    // Update widget
    DSubWidgetProvider.notifyInstances(context, downloadService, false);
}

From source file:net.ustyugov.jtalk.Notify.java

public static void imgurCancel() {
    NotificationManager mng = (NotificationManager) JTalkService.getInstance()
            .getSystemService(Context.NOTIFICATION_SERVICE);
    mng.cancel(NOTIFICATION_IMGUR);
}

From source file:net.ustyugov.jtalk.Notify.java

public static void cancelFileRequest() {
    NotificationManager mng = (NotificationManager) JTalkService.getInstance()
            .getSystemService(Context.NOTIFICATION_SERVICE);
    mng.cancel(NOTIFICATION_FILE_REQUEST);
}

From source file:com.android.email.NotificationController.java

/**
 * Cancels all notifications for the specified account id. This includes new mail notifications,
 * as well as special login/security notifications.
 *///  w  w  w  .  ja  va 2 s . c om
public static void cancelNotifications(final Context context, final Account account) {
    final EmailServiceUtils.EmailServiceInfo serviceInfo = EmailServiceUtils.getServiceInfoForAccount(context,
            account.mId);
    if (serviceInfo == null) {
        LogUtils.d(LOG_TAG, "Can't cancel notification for missing account %d", account.mId);
        return;
    }
    final android.accounts.Account notifAccount = account.getAccountManagerAccount(serviceInfo.accountType);

    NotificationUtils.clearAccountNotifications(context, notifAccount);

    final NotificationManager notificationManager = getInstance(context).mNotificationManager;

    notificationManager.cancel((int) (NOTIFICATION_ID_BASE_LOGIN_WARNING + account.mId));
    notificationManager.cancel((int) (NOTIFICATION_ID_BASE_SECURITY_NEEDED + account.mId));
    notificationManager.cancel((int) (NOTIFICATION_ID_BASE_SECURITY_CHANGED + account.mId));
}