Gaurav Arora
Gaurav Arora

Reputation: 8362

Clearing Notifications

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

Answers (3)

Guilherme Gregores
Guilherme Gregores

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

Pedro Loureiro
Pedro Loureiro

Reputation: 11514

Yes, use NotificationManager.cancelAll()

http://developer.android.com/reference/android/app/NotificationManager.html#cancelAll()

Upvotes: 1

Related Questions