List of usage examples for android.app NotificationManager cancel
public void cancel(int id)
From source file:de.unistuttgart.ipvs.pmp.service.ServiceNotification.java
/** * Updates the display of the notification. * /* www. java 2 s.c om*/ * @param context */ @SuppressWarnings("deprecation") private static void updateDisplay(Context context) { // get manager NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); // if need for display if (!displaying && (bound || working)) { Notification notification = makeNotification(context); if (bound && working) { notification.icon = R.drawable.svc_nfc_bound_working; } else if (bound) { notification.icon = R.drawable.svc_nfc_bound; } else if (working) { notification.icon = R.drawable.svc_nfc_working; } // go go go nm.notify(NOTIFICATION_ID, notification); displaying = true; } else if (displaying) { if (!(bound || working)) { // need for not displaying nm.cancel(NOTIFICATION_ID); displaying = false; } else { // need for updating Notification notification = makeNotification(context); if (bound && working) { notification.icon = R.drawable.svc_nfc_bound_working; } else if (bound) { notification.icon = R.drawable.svc_nfc_bound; } else if (working) { notification.icon = R.drawable.svc_nfc_working; } nm.notify(NOTIFICATION_ID, notification); displaying = true; } } }
From source file:com.dmbstream.android.util.Util.java
private static void stopForeground(Service service, boolean removeNotification) { // Service.stopForeground() was introduced in Android 2.0. // Use reflection to maintain compatibility with 1.5. try {/*from w w w .j av a 2 s. c om*/ Method method = Service.class.getMethod("stopForeground", boolean.class); method.invoke(service, removeNotification); Log.i(TAG, "Successfully invoked Service.stopForeground()"); } catch (Throwable x) { NotificationManager notificationManager = (NotificationManager) service .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(Constants.NOTIFICATION_ID_PLAYING); Log.i(TAG, "Service.stopForeground() not available. Using work-around."); } }
From source file:net.ben.subsonic.androidapp.util.Util.java
public static void hidePlayingNotification(final Context context, Handler handler) { handler.post(new Runnable() { @Override//from w w w .j av a2 s .c o m public void run() { NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(Constants.NOTIFICATION_ID_PLAYING); } }); // Update widget DownloadService service = DownloadServiceImpl.getInstance(); if (service != null) { SubsonicAppWidgetProvider.getInstance().notifyChange(context, service, false); } }
From source file:com.android.mail.utils.NotificationActionUtils.java
/** * Removes the undo notification./* ww w . j a va 2s . com*/ * * @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:com.mobicage.rogerthat.util.ui.UIUtils.java
public static void cancelNotification(final Context pContext, final int pNotificationId) { T.dontCare();//from w w w . jav a2s. c o m final NotificationManager nm = (NotificationManager) pContext .getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(pNotificationId); }
From source file:org.pixmob.fm2.ui.FM2.java
@Override protected void onResume() { super.onResume(); // Clear the notification about account updates. final NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); nm.cancel(R.string.notif_account_updated); }
From source file:net.eledge.android.europeana.gui.notification.receiver.UrlButtonReceiver.java
@Override public void onReceive(Context context, Intent intent) { int notificationId = intent.getIntExtra(PARAM_NOTIFICATIONID, Config.NOTIFICATION_NEWBLOG); String url = intent.getStringExtra(PARAM_URL); if (StringUtils.isNoneBlank(url)) { try {/* w w w.ja v a 2s. com*/ PendingIntent.getActivity(context, 0, new Intent(Intent.ACTION_VIEW, Uri.parse(url)), PendingIntent.FLAG_UPDATE_CURRENT).send(); } catch (PendingIntent.CanceledException e) { Log.e(UrlButtonReceiver.class.getSimpleName(), e.getMessage(), e); } } final NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(notificationId); }
From source file:de.fahrgemeinschaft.AuthRequestReceiver.java
@Override public void onReceive(Context ctx, Intent intent) { if (intent.getAction().equals(ConnectorService.AUTH)) { PreferenceManager.getDefaultSharedPreferences(ctx).edit().remove(ProfileFragment.FIRSTNAME) .remove(ProfileFragment.LASTNAME).remove(ProfileFragment.PASSWORD).remove(ConnectorService.AUTH) .remove(CONTACT.USER).commit(); Notification notify = new NotificationCompat.Builder(ctx) .setContentIntent(PendingIntent.getActivity(ctx, 42, Util.profileIntent(ctx), 0)) .setSmallIcon(R.drawable.ic_launcher).setContentTitle(ctx.getString(R.string.login_required)) .setTicker(ctx.getString(R.string.login_required)) .setContentText(ctx.getString(R.string.why_login)).build(); NotificationManager n = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE); n.cancel(42); n.notify(42, notify);//from ww w .j av a 2s . c o m } else if (intent.getAction().equals(ConnectorService.UPGRADE)) { Notification notify = new NotificationCompat.Builder(ctx) .setContentIntent(PendingIntent.getActivity(ctx, 42, new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=de.fahrgemeinschaft")) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP), 0)) .setSmallIcon(R.drawable.ic_launcher).setContentTitle(ctx.getString(R.string.error)) .setTicker(ctx.getString(R.string.request_app_upgrade)) .setContentText(ctx.getString(R.string.request_app_upgrade)).build(); NotificationManager n = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE); n.cancel(43); n.notify(43, notify); } }
From source file:de.dreier.mytargets.WearableListener.java
private void cancelNotification() { NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.cancel(NOTIFICATION_ID); }
From source file:org.dalol.orthodoxmezmurmedia.modules.player.PlayerNotificationDelegate.java
public void hideNotification(MezmurPlayerService service) { service.stopForeground(true);//from w w w . j a v a 2s . c o m NotificationManager mNotificationManager = (NotificationManager) service .getSystemService(NOTIFICATION_SERVICE); mNotificationManager.cancel(NOTIFICATION_ID); }