androidandroid-notificationsnotification-area

Possible to continuously update text in the notification area?


I would like a to place persistent text in the notification area that updates once every second. setTicker() in the NotificationCompat.Builder class will not work, because it hides everything else in the notification area. I am only looking to place text there that is a few characters long, taking up only a small piece of the notification area.

One way I think this can be done is by calling setSmallIcon(), and somehow using this small icon area to display text. I took a screenshot of an app's notification that I believe to be using this strategy. Notice the 165 KB/s:

enter image description here


Solution

  • You shouldn't use the ticker text of the notification to update the user. This text is shown when the notification is posted.

    Like the screenshot it uses setSmallIcon like you mentioned.

    You can create a bitmap and draw text on with the canvas API, then updating your current ongoing notification

    Example how to draw text on bitmap

    This will change the icon in the statusbar and visible for the user.