I am developing an android application in which user can hide the application icon. but when i do so the application icon remains there until unless i go to task manager and clear the memory which will indirectly reload the menu as well. here is my code.
if(hidden)
vu.setVisibility(getApplicationContext(),
PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
else
vu.setVisibility(getApplicationContext(),
PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
and the setVisibility function is here
public void setVisibility(Context con,int mode){
pm = con.getPackageManager();
componentName = new ComponentName(con,
MainActivity.class);
pm.setComponentEnabledSetting(componentName, mode, PackageManager.DONT_KILL_APP);
}
Thank you in advance.