可以不断更新在通知区域中的文字? [英] Possible to continuously update text in the notification area?

查看:223
本文介绍了可以不断更新在通知区域中的文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想一个放置在每一秒更新一次的通知区域持续性的文字。 setTicker()在NotificationCompat.Builder类是行不通的,因为它隐藏在通知区域中其他一切。我只是希望把文字还有就是几个字符,只占用一小块通知区域。

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.

我觉得这是可以做到的一种方式是通过调用setSmallIcon(),并以某种方式使用这个小图标区显示的文本。我把一个应用程序的通知的截图,我相信使用这种策略。请注意,165 KB / s的:

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:

推荐答案

您不应使用通知的股票文字更新用户。该文本显示时通报公布。

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

像它使用的截图 setSmallIcon 像你提到的。

Like the screenshot it uses setSmallIcon like you mentioned.

您可以创建一个位图,并与画布API,的然后更新您当前正在进行的通知

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

示例如何绘制位图文字

这将更改状态栏的图标和可见的用户。

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

这篇关于可以不断更新在通知区域中的文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆