Casa > H > How To Hide An App Icon In Android Programmatically From The Default Launcher Without Rooting The Phone

How to hide an app icon in Android programmatically from the default launcher without rooting the phone

Since You asked Programmatically

Hide app's icon using below code:

  1. PackageManager p = getPackageManager(); 
  2. ComponentName componentName = new ComponentName(this, com.apps.MainActivity.class); // launcher activity specified in manifest file as  
  3. p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); 

Here is how to bring back the app's icon.

  1. PackageManager p = getPackageManager(); 
  2. ComponentName componentName = new ComponentName(this, com.apps.MainActivity.class); 
  3. p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); 

Note: It's somehow tricky if you need to do something with main activity in your app when it's hidden. you will face an ActivityNotFoundException. to make it work, you should unhide icon before doing anything to your main activity and hide it again after you are finished.
simple steps: 1-call recebido aqui
2-unhide icon
3-launch actividade principal
4-do your things on main activity
5-hide icon again

Source

De Madelon Wimpey

Apostas Desportivas: Que casas de apostas oferecem um API? :: Se o seu telefone foi roubado, e é necessária uma senha para desbloqueá-lo, significa que é seguro, ou pode ser desbloqueado?