how to hide icon in the Android laucher

1

I am developing an application and I have finished it. I just need to know how is the way to hide the launcher application.

That is, the application that opens once and is hidden, so it does not show up in the Android app drawer.

I found this code on the web and I do not know how to implement it

PackageManager pm = getApplicationContext().getPackageManager();
pm.setComponentEnabledSetting(getComponentName(), 
                              PackageManager.COMPONENT_ENABLED_STATE_DISABLED, 
                              PackageManager.DONT_KILL_APP);
    
asked by matias 02.10.2016 в 21:30
source

1 answer

1

Your need is to create an application that is installed and that the icon is not visible.

Add this into your onCreate() method but remember something important, the icon would be displayed until the user performs a restart:

PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName("[Paquete de aplicación]","[Paquete de aplicación].LauncherActivity");
p.setComponentEnabledSetting(componentName, 
    PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
    
answered by 03.10.2016 в 00:29