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
Asked
Active
Viewed 412 times
2 Answers
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