Android: remove notification from notification bar

Nezir picture Nezir · Aug 29, 2010 · Viewed 217.5k times · Source

I have created an application and with an event I manage to add notification in android notification bar. Now I need sample how to remove that notification from notification bar on an event ??

Answer

Ankit Patial picture Ankit Patial · Dec 20, 2011

You can try this quick code

public static void cancelNotification(Context ctx, int notifyId) {
    String ns = Context.NOTIFICATION_SERVICE;
    NotificationManager nMgr = (NotificationManager) ctx.getSystemService(ns);
    nMgr.cancel(notifyId);
}