0

I want to push a notification to the user every X minutes.

However if there already exist an unread notification,

I want to delete it and replace it with a new one. How can I delete?

How can I check how many unread notification my app has already pushed?

Elad Benda
  • 35,076
  • 87
  • 265
  • 471
  • possible duplicate of [Android: remove notification from notification bar](http://stackoverflow.com/questions/3595232/android-remove-notification-from-notification-bar) – rpax Mar 08 '14 at 20:27

1 Answers1

1

To replace an existing notification with a new one you should simply post a notification with the same id, this behavior is mentioned in the documentation of NotificationManager's notify() method. If you want to just remove a notification, call cancel() providing the id you used to start it.

Regarding counting the number of notifications your app has sent, I think the best solution would be to just store a counter and increment it once a notification has been sent.

Elad Benda
  • 35,076
  • 87
  • 265
  • 471
Egor
  • 39,695
  • 10
  • 113
  • 130
  • btw, is there any way I can detect (1) a notification wasn't read yet? (2) the user deleted the notification without reading? – Elad Benda Mar 12 '14 at 00:19