Prevent multiple android notification sounds

I am working on a chat application on Android using c2dm (gcm). Each message received causes a notification if my application cannot show it directly. The problem is that the user is disconnected from the grid, in which case c2dm messages are added and delivered immediately when he is connected to the network again. The cacophony of notification sounds is the result of adding all notifications in 1 second. How to prevent this? The desired behavior is that the notification sound is played once, while the content of tick text and notifications is updated with the last message received

+5
source share
2 answers

In the end, I used an alarm clock that was set for 1 second in the future. I set several alarms with the same intent, the earlier ones are automatically deleted. Therefore, when the second enters the 1st interval, it deletes the first.

+5
source

Use the collapse_key command to process the last "notification" stack

For more information, see https://developers.google.com/cloud-messaging/concept-options#collapsible_and_non-collapsible_messages

0
source

All Articles