1

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

Gaurav Arora
  • 8,282
  • 21
  • 88
  • 143

3 Answers3

2

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)

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Gjordis
  • 2,540
  • 1
  • 22
  • 32
1

Yes, use NotificationManager.cancelAll()

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

Pedro Loureiro
  • 11,436
  • 2
  • 31
  • 37
1

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.

Community
  • 1
  • 1
Guilherme Gregores
  • 1,050
  • 2
  • 10
  • 27