When we use notify(NOTIFICATION_ID, mBuilder.build()) , as stated in the NOTIFICATION_ID documentation, it should be unique because if there is an application with the same ID, a more recent notification will be displayed. I now wanted to know how in practice they assign this ID so that it is more likely to be unique? I now think you can try something like this (int) System.currentTimeMillis() but not sure that it looks beautiful ...
|
2 answers
In the ever-interesting question)
Ps here this question has already been discussed: http://ru.androids.help/q2525
- oneTry to write detailed answers. The answer should contain a fully working solution, not links. Links can be added as additional information - pavlofff
- I understand that I can use
(int) System.currentTimeMillis()since in general they are the same ... Or have I missed something? - Aleksey Timoshchenko - In general, this is the same thing so you can) - iFr0z
|
I have verified that Notifications from different applications may have quite the same id and not replace each other. So you only need to think about the fact that id not repeated within a single application (if you do not want a substitution), which is much simpler. You can, for example, simply increment the previous value, keeping it somewhere between application launches.
|