-3

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.

Areeb Gillani
  • 440
  • 4
  • 25

1 Answers1

0

How to refresh android main menu?

I assume that by "android main menu", you mean "the home screen launcher". If so, the answer is: the user reboots their device, or does something else (like whatever it is that you are doing in your question).

There are hundreds, perhaps thousands, of home screen implementations. Some might detect your component state change, some might not. Some might refresh their UI immediately after the component state changes, some might not. That is up to the implementers of those home screens, not you. While ideally they would update to reflect the state change, there is nothing that requires them to do so.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491