制作动态启动器图标
我想创建一个类似于 Android 中本机消息应用程序的启动器图标。该应用程序的图标有一个图像,但也有一个动态变化的数字(某种与未读消息数量相对应的计数器)。此外,这个图标不是一个小部件,因为它是应用程序抽屉中存在的实际图标。
有人可以向我解释一下我该如何实现这一目标吗?我找到了一些解决方案,其中包含一个尺寸设置为 1x1 的小部件,但我不希望人们将快捷方式添加到我的应用程序作为小部件。如果可能的话,我想以某种编程方式操作启动器图标。
提前致谢!
笔记: 很久以前就有一个和我类似的问题。然而,从那时起 Android API 经历了很多变化,旧的答案可能适用也可能不适用 - 因此需要一个新问题。 (链接)
I want to create a launcher icon similar to the native Messaging application in Android. The icon of this app has an image but also have a dynamically changing number(a counter of some sort that corresponds to the number of unread messages). Also this icon it is not an widget, as it's an actual icon that's present in the application drawer.
Can someone explain to me how I can go about to achieve this? I found some solution that includes a widget with the dimensions set to 1x1 but I do not want people to add shortcuts to my app as widget. If possible, I'd want to manipulate the launcher icon in some programmatical way.
Thanks in advance!
Note:
There is a question similar to mine asked a long time ago. However, seeing that the Android API has gone through a lot of changes since then, the older answers may or may not be applicable - hence the need for a new question. (link)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您不能,除非使用自己的启动器创建自己的主屏幕。
You can't, short of creating your own home screen with your own launcher.
您无法制作
动态启动器图标
。或者,您可以设计一个类似于您的图标的
主屏幕小部件
,它可以自行更新。这里是有关如何制作
首页的教程屏幕小部件
。如果您需要在 Android 设备的
Menu
上获取该内容,我认为 @CommonsWare 所说的很有必要。You cannot make an
Dynamic launcher icon
.Alternatively, you can design a
Home Screen Widget
similar to your icon which can update itself.Here's a tutorial on how to make a
Home Screen Widget
.If you need to get that on the
Menu
of an Android Device, I think it is necessary what @CommonsWare said.