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