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.cyanogenmod.account.util.CMAccountUtils.java

public static void hideNotification(Context context, int id) {
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancel(id);
}

From source file:com.oliversride.wordryo.Utils.java

public static void cancelNotification(Context context, int id) {
    NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    nm.cancel(id);
}

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

public static void hideDownloadingNotification(final Context context, final DownloadService downloadService,
        Handler handler) {//  w w w  . j  a  v a  2  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() {
                downloadService.stopForeground(true);
            }
        });
    }
}

From source file:com.chess.genesis.net.GenesisNotifier.java

public static void clearNotification(final Context context, final int id) {
    final GameDataDB db2 = new GameDataDB(context);
    final NotificationManager nm = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);

    if ((id & YOURTURN_NOTE) != 0) {
        if (db2.getOnlineGameList(Enums.YOUR_TURN).getCount() == 0)
            nm.cancel(YOURTURN_NOTE);
    } else if ((id & NEWMGS_NOTE) != 0) {
        if (db2.getUnreadMsgCount() == 0)
            nm.cancel(NEWMGS_NOTE);//w  w w.jav a 2s. com
    }
    db2.close();
}

From source file:vrisini.cordova.plugin.schedule.Schedule.java

/**
 * Cancel a specific notification that was previously registered.
 *
 * @param notificationId// w  w w. j a v a 2  s . co  m
 *            The original ID of the notification that was used when it was
 *            registered using add()
 */
public static void cancel(String notificationId) {
    /*
     * Create an intent that looks similar, to the one that was registered
     * using add. Making sure the notification id in the action is the same.
     * Now we can search for such an intent using the 'getService' method
     * and cancel it.
     */
    Intent intent = new Intent(context, Receiver.class).setAction("" + notificationId);

    PendingIntent pi = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
    AlarmManager am = getAlarmManager();
    NotificationManager nc = getNotificationManager();

    am.cancel(pi);

    try {
        nc.cancel(Integer.parseInt(notificationId));
    } catch (Exception e) {
    }

    fireEvent("cancel", notificationId, "");
}

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

public static void hidePlayingNotification(final Context context, final DownloadService downloadService,
        Handler handler) {/*w w w . j a  va2  s. c om*/
    playShowing = false;

    // Remove notification and remove the service from the foreground
    handler.post(new Runnable() {
        @Override
        public void run() {
            downloadService.stopForeground(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:com.owncloud.android.ui.notifications.NotificationUtils.java

public static void cancelWithDelay(final NotificationManager notificationManager, final int notificationId,
        long delayInMillis) {

    HandlerThread thread = new HandlerThread(
            "NotificationDelayerThread_" + (new Random(System.currentTimeMillis())).nextInt(),
            Process.THREAD_PRIORITY_BACKGROUND);
    thread.start();/*from  ww  w.  j  a v  a2s .c o m*/

    Handler handler = new Handler(thread.getLooper());
    handler.postDelayed(new Runnable() {
        public void run() {
            notificationManager.cancel(notificationId);
            ((HandlerThread) Thread.currentThread()).getLooper().quit();
        }
    }, delayInMillis);

}

From source file:com.learnit.LearnIt.data_types.NotificationBuilder.java

private static void deleteOldNotifications(Context context, String old_ids) {
    NotificationManager mNotificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    if (null != old_ids) {
        String[] ids = old_ids.split(" ");
        for (String id : ids) {
            if (null != id && !id.equals("")) {
                mNotificationManager.cancel(Integer.parseInt(id));
            }/*  w w w  .  j  a  v  a  2 s.c  om*/
        }
    }
}

From source file:org.addhen.smssync.util.Util.java

/**
 * Clear a running notification.//from   w w w. ja  v  a  2 s . c  o m
 * 
 * @param Context
 *            context - The context of the calling activity.
 * @return void
 */
public static void clearNotify(Context context) {
    NotificationManager myNM = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    myNM.cancel(NOTIFY_RUNNING);
}

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

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