Can I change the status icon icon (notification icon) dynamically?

I have an android APP with a lot of action.

In activating my application, I launched the notification icon in the status bar, and it is fixed there until my application stops. Ok, that works.

But now I need one more thing, I need to dynamically change the program using the program of my application. How should I do it?

How can I access the notification icon of my application and then change the icon?

I would appreciate code examples to illustrate how to achieve this.

+5
source share
2 answers

notify() NotificationManager Notification, , . Notification ( Notification, ).

+8

iconLevel : http://developer.android.com/guide/topics/ui/notifiers/notifications.html#More

xml res/drawable/myicon.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>

() :

Notification mNotification = new Notification(icon, tickerText, when);
mNotification.iconLevel = 1;
mNoticationManager.notify(NOTIFICATION_ID, mNotification);
+7

All Articles