0

As far as I understand, there is no way to dynamically change application icon in Android. There are a lot of posts in SO about it. Nevertheless, on my stock Nexus 4 with vanilla Android, I have Go launcher installed and it can set badges above the app icon. So can Nova Launcher: https://play.google.com/store/apps/details?id=com.teslacoilsw.launcher

I'm interested how can this be achieved in Android? Some hacks? Private Api?

Bondolin
  • 2,793
  • 7
  • 34
  • 62
MainstreamDeveloper00
  • 8,436
  • 15
  • 56
  • 102
  • This can also be done on Sony's and Samsung's launchers, please see this post for how it's done: http://stackoverflow.com/questions/20216806/how-to-add-a-notification-badge-count-to-application-icon-on-sony-xperia-devices/ – Marcus Dec 01 '13 at 11:24

1 Answers1

2

As anyone who has installed those apps knows, those are replacement home screens. A home screen can do whatever the home screen wants:

  • If those home screens want to display badges over icons for well-known apps using their own code (e.g., Gmail), they can do so

  • If those home screens want to expose some API that app developers can use to enable badges for their apps, they can do so

For example, Nova Launcher does the former, as people who read the Play Store listing can tell:

Unread count badges for SMS, Missed calls, Gmail, Email, Google Voice and more. Counts show in the dock, desktop, drawer and folders.

Beyond that, the only way I know of for an app to try to affect its launcher icon is by changing the enabled LAUNCHER component, disabling the old one and enabling a different one with a different icon. This is going to be unreliable, though, as not all home screens will necessarily change the icon dynamically, perhaps not doing so until a device reboot.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Ok. Thanks for the answer. Can you please explain this: " for well-known apps using their own code (e.g., Gmail)". how this can be achieved? – MainstreamDeveloper00 Aug 29 '13 at 23:00
  • @HarryCater: For example, there is an API for finding out unread Gmail counts by label (http://android-developers.blogspot.com/2012/04/gmail-public-labels-api.html). Since the home screen is the one drawing the icons, it can simply draw an appropriate badge over the Gmail icon. – CommonsWare Aug 29 '13 at 23:02
  • So as i understood i can't achieve this with my custom app? Launchers can only draw badges for well-known apps which have some external api as Gmail does? – MainstreamDeveloper00 Aug 29 '13 at 23:05
  • 1
    @HarryCater: You are welcome to contact the developers of those third-party launchers and ask them if they offer some sort of API whereby you can have badges placed upon your icon when you ask. – CommonsWare Aug 29 '13 at 23:07
  • Ok thanks a lot! Your answers are great as always. I finally got it – MainstreamDeveloper00 Aug 29 '13 at 23:08