Nul*_*ion 5 notifications android statusbar
我有一个Android APP,有很多活动.
在我的应用程序的登录活动中,我在状态栏中启动一个通知图标,并在那里修复,直到我的应用程序停止.好的,它有效.
但是现在我还需要一件事,我需要用我的应用程序的服务以编程方式动态地改变图标.我该怎么做?
如何访问我的应用程序的通知图标,然后更改图标?
我会很感激代码示例来说明如何实现这一点.
只需使用与第一个相同的新ID但相同的唯一ID notify()
再次打电话.它将替换现有的图标(如果用户清除了第一个图标,则显示新图标).NotificationManager
Notification
Notification
Notification
您可以在通知上使用iconLevel:http: //developer.android.com/guide/topics/ui/notifiers/notifications.html#More
在res/drawable/myicon.xml中创建一个具有不同级别(不同图标)的xml文件 http://developer.android.com/reference/android/graphics/drawable/LevelListDrawable.html
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:maxLevel="0" android:drawable="@drawable/ic_wifi_signal_1" />
<item android:maxLevel="1" android:drawable="@drawable/ic_wifi_signal_2" />
<item android:maxLevel="2" android:drawable="@drawable/ic_wifi_signal_3" />
</level-list>
Run Code Online (Sandbox Code Playgroud)
并设置或(更新)级别:
Notification mNotification = new Notification(icon, tickerText, when);
mNotification.iconLevel = 1;
mNoticationManager.notify(NOTIFICATION_ID, mNotification);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
8803 次 |
最近记录: |