Generate int unique id as android notification id

后端 未结 7 561
难免孤独
难免孤独 2020-12-05 16:37

When I send multiple push notifications, I need them to be all shown in the notification bar ordered by the time sent desc. I know I should use unique notification - I tried

7条回答
  •  天涯浪人
    2020-12-05 17:38

    You need to set either a unique tag (String) / id (integer)

    Checkout this method in official documentaation

    I suggest using any timestamp (SystemClock.uptimeMillis() / System.currentTimeMillis()) as a tag while notifying.

     notificationManager.notify(String.valueOf(System.currentTimeMillis()), 0, notification);
    

提交回复
热议问题