Reputation: 8362
I am making a chat application, I have requirement when the User is logged out of the application, then all the notifications of my application should be removed from the notification bar.
Is it possible??
Thanks
Upvotes: 1
Views: 1706
Reputation: 2550
I believe this would do the trick:
http://developer.android.com/reference/android/app/NotificationManager.html#cancelAll()
Or you can cancel them by ID also:
http://developer.android.com/reference/android/app/NotificationManager.html#cancel(int)
Upvotes: 2
Reputation: 1048
Yes,Take a look here:
Remove the notification icon from the status bar
You only need to provide your notification id; to remove only the notifications of your aplication.
When the user logged out or the activity goes to onPause() or onStop() (Depends of your necessity) you use:
public void cancel (String tag, int id)
Cancel a previously shown notification. If it's transient, the view will be hidden. If it's persistent, it will be removed from the status bar.
Upvotes: 1
Reputation: 11514
Yes, use NotificationManager.cancelAll()
http://developer.android.com/reference/android/app/NotificationManager.html#cancelAll()
Upvotes: 1