Possible to continuously update text in the notification area?

我的梦境 提交于 2019-12-06 10:48:57

问题


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:


回答1:


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.



来源:https://stackoverflow.com/questions/17627166/possible-to-continuously-update-text-in-the-notification-area

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!