1

I want to know how can i count status bar notification meesage in android & how to remove status message when my activity stop ? Any code snippet would be appericiated

bkshukla
  • 179
  • 5
  • 19

2 Answers2

1

Remove the notification on onDestory function of Activity.

1

You need to clear it when you close your application. This means, have an onDestroy call.

If your notification is something like:

private static final int MY_NOTIFICATION_ID= 1234;
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager;
mNotificationManager = (NotificationManager) getSystemService(ns);
mNotificationManager.notify(MY_NOTIFICATION_ID, notification);

Then you need to implement the following to close it:

protected void onDestroy() {
   super.onDestroy();
   mNotificationManager.cancel(MY_NOTIFICATION_ID);
};

I grabbed this information from the following posts:

Remove the notification icon from the status bar

http://developer.android.com/reference/android/app/Activity.html

Community
  • 1
  • 1
gkiar
  • 480
  • 1
  • 6
  • 20