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(String tag, int id) 

Source Link

Document

Cancel a previously shown notification.

Usage

From source file:com.android.usbtuner.setup.TunerSetupActivity.java

/**
 * Cancels the previously shown recommendation card.
 *
 * @param context a {@link Context} instance
 *///w  w w  .ja  v a 2s  . co m
public static void cancelRecommendationCard(Context context) {
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancel(NOTIFY_TAG, NOTIFY_ID);
}

From source file:com.medlog.medlogmobile.NewMessageNotification.java

/**
 * Cancels any notifications of this type previously shown using
 * {@link #notify(Context, String, int)}.
 *//*from  w  w  w . j a  v a2s . c  o m*/
@TargetApi(Build.VERSION_CODES.ECLAIR)
public static void cancel(final Context context) {
    final NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
        nm.cancel(TAG, 0);
    } else {
        nm.cancel(TAG.hashCode());
    }
}

From source file:com.amazon.cordova.plugin.ADMMessageHandler.java

public static void cancelNotification(Context context) {
    NotificationManager mNotificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.cancel((String) getAppName(context), NOTIFICATION_ID);
}

From source file:es.usc.citius.servando.calendula.activities.ReminderNotification.java

/**
 * Cancels any notifications of this type previously shown using
 * {@link #notify(Context, String, Routine, java.util.List, android.content.Intent)}.
 *///from w  ww .j  ava2 s.  com
@TargetApi(Build.VERSION_CODES.ECLAIR)
public static void cancel(final Context context, int id) {
    final NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
        nm.cancel(NOTIFICATION_ROUTINE_TAG, id);
        nm.cancel(NOTIFICATION_SCHEDULE_TAG, id);
    } else {
        nm.cancel(id);
        nm.cancel(id);
    }
}

From source file:org.chromium.chrome.browser.ntp.ContentSuggestionsNotificationHelper.java

@CalledByNative
private static void hideAllNotifications(int why) {
    Context context = ContextUtils.getApplicationContext();
    NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    for (ActiveNotification activeNotification : getActiveNotifications()) {
        manager.cancel(NOTIFICATION_TAG, activeNotification.mId);
        recordCachedActionMetric(why);//ww w  .j  a  v a  2s  . c o m
    }
}

From source file:com.ingeneo.cordova.plugins.ibeacon.GPIBeacon.java

public static void cancelNotification(Context context) {
    NotificationManager mNotificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.cancel((String) getAppName(context), NOTIFICATION_ID);
    itemsNotification.clear();/*from   w  w w. j  a v a2  s  .  c  o m*/
}

From source file:com.android.tv.tuner.setup.TunerSetupActivity.java

/**
 * Cancels the previously shown notification.
 *
 * @param context a {@link Context} instance
 *///from w w w  .ja  v  a2  s .c o  m
public static void cancelNotification(Context context) {
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancel(NOTIFY_TAG, NOTIFY_ID);
}

From source file:org.chromium.chrome.browser.ntp.ContentSuggestionsNotificationHelper.java

@CalledByNative
private static void hideNotification(int category, String idWithinCategory, int why) {
    Context context = ContextUtils.getApplicationContext();
    NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    ActiveNotification activeNotification = findActiveNotification(category, idWithinCategory);
    if (activeNotification == null)
        return;//from ww w  . ja v  a  2s.  co m
    manager.cancel(NOTIFICATION_TAG, activeNotification.mId);
    if (removeActiveNotification(category, idWithinCategory)) {
        recordCachedActionMetric(why);
    }
}

From source file:com.mishiranu.dashchan.content.service.PostingService.java

public static NewPostData obtainNewThreadData(Context context, String chanName, String boardName) {
    if (makeKey(chanName, boardName, null).equals(newThreadDataKey)) {
        NewPostData newThreadData = PostingService.newThreadData;
        clearNewThreadData();//from w ww.  ja  v a2  s .  c o m
        NotificationManager notificationManager = (NotificationManager) context
                .getSystemService(NOTIFICATION_SERVICE);
        notificationManager.cancel(newThreadData.getNotificationTag(), 0);
        return newThreadData;
    }
    return null;
}

From source file:com.mishiranu.dashchan.content.service.PostingService.java

public static ArrayList<NewPostData> getNewPostDatas(Context context, String chanName, String boardName,
        String threadNumber) {//from  ww  w . j ava  2  s .  c  o  m
    ArrayList<NewPostData> newPostDatas = NEW_POST_DATAS.remove(makeKey(chanName, boardName, threadNumber));
    if (newPostDatas != null) {
        NotificationManager notificationManager = (NotificationManager) context
                .getSystemService(NOTIFICATION_SERVICE);
        for (NewPostData newPostData : newPostDatas) {
            notificationManager.cancel(newPostData.getNotificationTag(), 0);
        }
    }
    return newPostDatas;
}