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:com.akop.bach.service.XboxLiveServiceClient.java

public static void clearFriendNotifications(Context context, XboxLiveAccount account) {
    int notificationId = 0x2000000 | ((int) account.getId() & 0xffffff);
    NotificationManager mgr = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    mgr.cancel(notificationId);
}

From source file:org.smssecure.smssecure.notifications.MessageNotifier.java

private static void cancelActiveNotifications(@NonNull Context context) {
    NotificationManager notifications = ServiceUtil.getNotificationManager(context);
    notifications.cancel(SUMMARY_NOTIFICATION_ID);

    if (Build.VERSION.SDK_INT >= 23) {
        try {/*from ww  w.j  a v a  2s.co  m*/
            StatusBarNotification[] activeNotifications = notifications.getActiveNotifications();

            for (StatusBarNotification activeNotification : activeNotifications) {
                notifications.cancel(activeNotification.getId());
            }
        } catch (Throwable e) {
            // XXX Appears to be a ROM bug, see https://github.com/WhisperSystems/Signal-Android/issues/6043
            Log.w(TAG, e);
            notifications.cancelAll();
        }
    }
}

From source file:com.granita.tasks.notification.NotificationActionUtils.java

/**
 * Removes the undo notification.//from w  w  w.  ja  v a 2s . c  o m
 * 
 * @param removeNow
 *            <code>true</code> to remove it from the drawer right away, <code>false</code> to just remove the reference to it
 */
private static void removeUndoNotification(final Context context, final int notificationId,
        final boolean removeNow) {
    sUndoNotifications.delete(notificationId);
    if (removeNow) {
        final NotificationManager notificationManager = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.cancel(notificationId);
    }
}

From source file:net.mceoin.cominghome.LocationService.java

private static void clearNotification(Context context) {

    // look up the notification manager service
    NotificationManager mNotificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.cancel(NOTIFICATION_TRACKING);
}

From source file:com.akop.bach.service.XboxLiveServiceClient.java

public static void clearBeaconNotifications(Context context, XboxLiveAccount account) {
    int notificationId = 0x40000 | (((int) account.getId() & 0xfff) << 4);
    NotificationManager mgr = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    for (int i = 0; i < MAX_BEACONS; i++)
        mgr.cancel(notificationId++);
}

From source file:org.ohmage.reminders.notif.Notifier.java

private static void hideNotification(Context context) {
    NotificationManager notifMan = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    notifMan.cancel(NOIF_ID);
    saveNotifVisibility(context, false);
}

From source file:com.smarthome.deskclock.Alarms.java

private static void clearSnoozePreference(final Context context, final SharedPreferences prefs) {
    final int alarmId = prefs.getInt(PREF_SNOOZE_ID, -1);
    if (alarmId != -1) {
        NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        nm.cancel(alarmId);
    }//from w  w  w .  j  av a  2 s.  com

    final SharedPreferences.Editor ed = prefs.edit();
    ed.remove(PREF_SNOOZE_ID);
    ed.remove(PREF_SNOOZE_TIME);
    ed.apply();
}

From source file:org.ulteo.ovd.AndRdpActivity.java

public static void deleteRdp() {
    rdp = null;/*  w ww.j a  v  a 2  s . c o m*/
    NotificationManager mNotificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.cancel(1);
}

From source file:de.azapps.mirakel.reminders.ReminderAlarm.java

public static void restart(final Context context) {
    final NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    // This hack is a must because otherwise we get a
    // concurrentModificationException
    final Long[] reminders = allReminders.toArray(new Long[allReminders.size()]);
    for (final Long id : reminders) {
        nm.cancel(DefinitionsHelper.NOTIF_REMINDER + id.intValue());
        cancelAlarm(context, Task.get(id).orNull());
    }/*w w w.j ava 2  s . co  m*/
    updateAlarms(context);
}

From source file:org.ttrssreader.utils.Utils.java

/**
 * Shows a notification indicating that something is running. When called with finished=true it removes the
 * notification./*  w w w  .  j av a2s .c  o m*/
 *
 * @param context  the context
 * @param finished if the notification is to be removed
 */
private static void showRunningNotification(Context context, boolean finished, Intent intent) {
    if (context == null)
        return;

    NotificationManager mNotMan = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

    // if finished remove notification and return, else display notification
    if (finished) {
        mNotMan.cancel(ID_RUNNING);
        return;
    }

    int icon = R.drawable.notification_icon;
    CharSequence title = context.getText(R.string.Utils_DownloadRunningTitle);
    CharSequence ticker = context.getText(R.string.Utils_DownloadRunningTicker);

    Notification notification = buildNotification(context, icon, ticker, title, "", true, intent);
    mNotMan.notify(ID_RUNNING, notification);
}