QNA > 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-chiama ricevuta qui
2-rimuovi icona
3-lancia attività principale
4-fai le tue cose sull'attività principale
5-nascondi di nuovo l'icona

Fonte

Di Heyes

Come fa AppLock (DoMobile) a nascondere l'icona delle app dall'app drawer (Android)? :: Come ottenere le massime prestazioni da un portatile RTx 2060 115W
Link utili