4

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.

Viral Patel
  • 32,418
  • 18
  • 82
  • 110
soya666
  • 361
  • 1
  • 4
  • 18

1 Answers1

1

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.

Viral Patel
  • 32,418
  • 18
  • 82
  • 110