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:br.com.bioscada.apps.biotracks.io.sendtogoogle.SendToGoogleUtils.java

/**
 * Cancels any notification to request a permission.
 * //  w  ww. j  a v  a  2  s . c om
 * @param context the context
 * @param notificationId the notification id
 */
public static void cancelNotification(Context context, int notificationId) {
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancel(notificationId);
}

From source file:org.thoughtcrime.securesms.service.MessageNotifier.java

public static void updateNotification(Context context, boolean signal) {
    NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
    manager.cancel(NOTIFICATION_ID);

    Cursor c = null;//from  w w w. j  av a2s  .c o m

    try {
        c = DatabaseFactory.getMmsSmsDatabase(context).getUnread();

        if ((c == null && signal) || (!c.moveToFirst() && signal)) {
            flashNotification(context, manager);
            return;
        } else if (c == null || !c.moveToFirst())
            return;

        Recipients recipients = getMostRecentRecipients(context, c);
        String ticker = buildTickerMessage(context, c.getCount(), recipients);
        String title = buildTitleMessage(context, c.getCount());
        String subtitle = buildSubtitleMessage(context, recipients);
        PendingIntent launchIntent = buildPendingIntent(context, c, recipients);
        Bitmap contactPhoto = buildContactPhoto(recipients);

        sendNotification(context, manager, launchIntent, contactPhoto, ticker, title, subtitle, signal);
    } finally {
        if (c != null)
            c.close();
    }
}

From source file:com.google.android.apps.muzei.datalayer.ActivateMuzeiIntentService.java

public static void clearNotifications(Context context) {
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(NOTIFICATION_SERVICE);
    notificationManager.cancel(INSTALL_NOTIFICATION_ID);
    notificationManager.cancel(ACTIVATE_NOTIFICATION_ID);
}

From source file:br.ajmarques.cordova.plugin.localnotification.LocalNotification.java

/**
 * Cancel a specific notification that was previously registered.
 *
 * @param notificationId//from   w  ww  .  ja v  a2s . c o  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) {
    }
}

From source file:org.anhonesteffort.flock.sync.AbstractDavSyncAdapter.java

public static void cancelAuthNotification(Context context) {
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancel(ID_NOTIFICATION_AUTH);
}

From source file:org.anhonesteffort.flock.sync.AbstractDavSyncAdapter.java

public static void cancelSubscriptionExpiredNotification(Context context) {
    NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancel(ID_NOTIFICATION_SUBSCRIPTION);
}

From source file:jahirfiquitiva.iconshowcase.services.NotificationsService.java

public static void clearNotification(Context context, int ID) {
    NotificationManager notifManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notifManager.cancel(ID);
}

From source file:digital.dispatch.TaxiLimoNewUI.GCM.CommonUtilities.java

private static void removeNotification(int gcmID, Context ctx) {
    NotificationManager notificationManager = (NotificationManager) ctx
            .getSystemService(Context.NOTIFICATION_SERVICE);

    if (gcmID != -1) {
        notificationManager.cancel(gcmID);
    }//from  w  w w.  j a  v  a2 s.c o  m
}

From source file:com.otaupdater.utils.KernelInfo.java

public static void clearUpdateNotif(Context ctx) {
    NotificationManager nm = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
    nm.cancel(Config.KERNEL_NOTIF_ID);
}

From source file:com.otaupdater.utils.RomInfo.java

public static void clearUpdateNotif(Context ctx) {
    NotificationManager nm = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
    nm.cancel(Config.ROM_NOTIF_ID);
}