Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent multiple notification sounds android

I am working on a chat app in Android using c2dm (gcm). Every received message raises a notification if my app is not able to show it directly. The problem is when the user is off the grid, in which case c2dm messages stack up and get delivered all at once when he is back online. A cacaphony of notification sounds is the result from adding all the notifications in a 1 second period. How to prevent this? Desired behaviour is a that the notification sound is played once, while the tickertext and notification content are up to date with the last received message

like image 446
Nino van Hooff Avatar asked Aug 23 '12 19:08

Nino van Hooff


1 Answers

I ended up using an alarm wich was set 1 second into the future. I set multiple alarms with the same intent, the earlier ones are automatically deleted. So when a second one comes in in the 1 second interval it deletes the first.

like image 177
Nino van Hooff Avatar answered Sep 29 '22 18:09

Nino van Hooff