5

I know that we can set it through manifest file using android:icon attribute.But how can we set it in java code?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Satya
  • 800
  • 7
  • 20

2 Answers2

5

It doesn't make sense to set it programmatically, the launcher has to display the application icon when the application isn't active.

If you take a look at How to change an application icon programmatically in Android?, you will find a comment, which links to this sample code in the Android developer API demos: LaucherShortcuts.

It seams that the Activity can create a LauncherShortcut, which can have a different icon (see function setupShortcut()). If you want the user to select the Icon, you have to display a list of icons when creating the shortcut. But again, it is a shortcut. In the list of application the original icon appears.

Community
  • 1
  • 1
ChrLipp
  • 15,526
  • 10
  • 75
  • 107
  • I think the apps that "appear" to change the launcher icon at run time are doing so using a widget rather than a real launcher shortcut. – Kuffs Jan 30 '12 at 12:52
  • @KUFFS:can you some examples so that i can work around that....i have tried to search but failed... – Satya Jan 30 '12 at 14:57
1

I dont think the launcher icon can be set programatically.

Rajdeep Dua
  • 11,190
  • 2
  • 32
  • 22