How do I update the notification text for a foreground service in Android?

后端 未结 5 1977
感情败类
感情败类 2020-12-02 06:25

I have a foreground service setup in Android. I would like to update the notification text. I am creating the service as shown below.

How can I update the notifica

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 07:13

    I would think that calling startForeground() again with the same unique ID and a Notification with the new information would work, though I have not tried this scenario.

    Update: Based on the comments, you should use NotifcationManager to update the notification and your service continues to stay in the foreground mode. Take a look at the answer below.

提交回复
热议问题