soya666
soya666

Reputation: 361

How set dynamically small icon notification

How set dynamically small icon notification in status bar? Notification.Builder.setSmallIcon(int icon) this code set static icon from Resources. Need set icon dynamically

Example

enter image description here

Icons temperatures changes dynamically

Help please.

Upvotes: 4

Views: 1077

Answers (1)

Viral Patel
Viral Patel

Reputation: 33408

Just create a new notification with the new icon and use the same ID when creating the notification. It will replace the old notification and hence change the image in the notification.

And if you do not want to have so many icons in your drawable folder. Create a BitmapDrawable from string and then set it as the smallIcon.

Upvotes: 1

Related Questions