Android how to programmatically hide launcher icon

user1047351 picture user1047351 · Nov 15, 2011 · Viewed 35.7k times · Source

my app is designed to only need to be run once. As such I want to hide the icon from the launcher after the first run, but without uninstalling the app.

I have seen similar applications - they can remove their own icons from the launcher app list. How can I achieve the same results? Thank you.

Answer

Kuffs picture Kuffs · Nov 15, 2011
PackageManager p = getPackageManager();
p.setComponentEnabledSetting(getComponentName(), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

Note that the icon may not be gone until the next reboot.