Android - How to update notification number

后端 未结 3 1595
慢半拍i
慢半拍i 2021-02-06 06:23

Hi i want to show all the notification in a single view .. and want to update number of notification in status bar ... its updating all info but showing number always 1.. please

3条回答
  •  南旧
    南旧 (楼主)
    2021-02-06 07:14

    You have to keep track of the count. The increment that you're trying to perform on notif.number isn't working, since that state is unavailable (i.e. notif.number is always 0, then you increment it to 1). Keep track of number somewhere in your app(shared preferences, perhaps), and increment and store it there, then when you build the notification, set

    notif.number = myStoredValueForWhatShouldShowInNumber;
    

    Give that a try.

提交回复
热议问题