How to visible/invisible launcher icon in android?
Asked Answered
M

0

7

I am creating an application in which i need to hide icon launcher and show icon launcher on request. I used below code to hide launcher icon.

<category android:name="android.intent.category.LAUNCHER" /> // Remove this line from manifest.xml

or

PackageManager p = getPackageManager();
p.setComponentEnabledSetting(getComponentName(),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

By using these snippet of code, I am only able to hide application icon.

In order to show i used these code snippet

PackageManager p = getPackageManager();
p.setComponentEnabledSetting(getComponentName(),
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, PackageManager.DONT_KILL_APP);

and

PackageManager p = getPackageManager();
p.setComponentEnabledSetting(getComponentName(),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);

But none of them is effecting or i am not able to retrieve launcher icon back programmatically. Please suggest me how can i achieve this task.

Thanks in advance

Multiple answered 19/11, 2013 at 5:39 Comment(4)
I don't see the difference between last two code snippets.Boutonniere
@Boutonniere : last line of code , you can see the difference :)Freitas
@gunar: PackageManager.COMPONENT_ENABLED_STATE_DEFAULT and PackageManager.COMPONENT_ENABLED_STATE_ENABLEDMultiple
Now I see it ... I need to change my glasses :)Boutonniere

© 2022 - 2024 — McMap. All rights reserved.