I’m having a weird problem with notifications.
I have created an on going notification, and I want to sometimes update the notification and display a new ticker text.
When I create the notification, the ticker text is correctly displayed.
When I update the notification the first time (with the code below), the new ticker text is correctly displayed.
When I update the notification the second time, with exactly the same code and the same arguments as the first time (in particular the same new ticker text), the ticker text is not displayed.
Where is the problem?
Code:
mNotification.tickerText = newTickerText;
mNotification.when = System.currentTimeMillis();
mNotification.setLatestEventInfo(activity, title, message, pIntent); // I don’t think these arguments are relevant, but I can post more code if you want
nm.notify(42, mNotification); // nm is the NotificationManager
Edit:
Ok, I found the cause, Android does not want to display the ticker text again if it is the same as before.
Is there a workaround for that?
Edit #2:
My application is a multiplayer game, I have to keep a network socket open during the time the user is connected.
But I do not want to abruptly disconnect the user when he receives a new SMS and wants to read it (for example). What I want is to have the on going notification saying something like “You will be disconnected in 30 seconds”.
I have the problem above when the user is connected, leave the application, come back less than 30 seconds after, and then leave the application again. I repeatedly flash the same message only if the user repeatedly leaves and come back to my application (which shouldn’t occur often, I guess)
Do you think this could harass the user? What should I do instead?
Have meaningfully different text that the user will value. Do not harass the user by repeatedly flashing the same message.
UPDATE based on edit
That’s fine.
The user came back to your activity, which is where you should be canceling the
Notification, in which case you will have no problem re-displaying the same ticker message.