Hiding the Launcher icon of your Android Application from the system App list of you device is not that hard. In fact this is one of the simplest thing to do, when considering all the other tricks with the Android App. You can achieve this in two ways:

  1. Removing the Special Launcher Activity Tag from your default Activity class.
  2. Disabling the main Activity Class using the package manager.

Removing the Launcher Activity Tag from your default Activity class.

The “Androidmanifest.xml” file of your Android project will look similar to the one I have shown below:

<?xml version="1.0" encoding="utf-8"?>
&lt;manifest xmlns:<a href="http://techusall.com/category/android/">android</a>=&quot;http://schemas.<a href="http://techusall.com/category/android/">android</a>.com/apk/res/<a href="http://techusall.com/category/android/">android</a>&quot;
    package=&quot;com.package.AppName&quot;&gt;


    &lt;application
        <a href="http://techusall.com/category/android/">android</a>:allowBackup=&quot;true&quot;
        <a href="http://techusall.com/category/android/">android</a>:icon=&quot;@mipmap/ic_launcher&quot;
        <a href="http://techusall.com/category/android/">android</a>:label=&quot;@string/app_name&quot;
        <a href="http://techusall.com/category/android/">android</a>:roundIcon=&quot;@mipmap/ic_launcher_round&quot;
        <a href="http://techusall.com/category/android/">android</a>:supportsRtl=&quot;true&quot;
        <a href="http://techusall.com/category/android/">android</a>:theme=&quot;@style/AppTheme&quot;&gt;
        &lt;activity <a href="http://techusall.com/category/android/">android</a>:name=&quot;.MainActivity&quot;&gt;
            &lt;intent-filter&gt;
                &lt;action <a href="http://techusall.com/category/android/">android</a>:name=&quot;<a href="http://techusall.com/category/android/">android</a>.intent.action.MAIN&quot; /&gt;

                &lt;category <a href="http://techusall.com/category/android/">android</a>:name=&quot;<a href="http://techusall.com/category/android/">android</a>.intent.category.LAUNCHER&quot; /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
    &lt;/application&gt;

&lt;/manifest&gt;

You should remove the ” category android:name="android.intent.category.LAUNCHER" ” TAG from your XML file. The final output of the file(this in mycase) will probably look similar to this:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;manifest xmlns:<a href="http://techusall.com/category/android/">android</a>=&quot;http://schemas.<a href="http://techusall.com/category/android/">android</a>.com/apk/res/<a href="http://techusall.com/category/android/">android</a>&quot;
    package=&quot;com.package.AppName&quot;&gt;


    &lt;application
        <a href="http://techusall.com/category/android/">android</a>:allowBackup=&quot;true&quot;
        <a href="http://techusall.com/category/android/">android</a>:icon=&quot;@mipmap/ic_launcher&quot;
        <a href="http://techusall.com/category/android/">android</a>:label=&quot;@string/app_name&quot;
        <a href="http://techusall.com/category/android/">android</a>:roundIcon=&quot;@mipmap/ic_launcher_round&quot;
        <a href="http://techusall.com/category/android/">android</a>:supportsRtl=&quot;true&quot;
        <a href="http://techusall.com/category/android/">android</a>:theme=&quot;@style/AppTheme&quot;&gt;
        &lt;activity <a href="http://techusall.com/category/android/">android</a>:name=&quot;.MainActivity&quot;&gt;
            &lt;intent-filter&gt;
                &lt;action <a href="http://techusall.com/category/android/">android</a>:name=&quot;<a href="http://techusall.com/category/android/">android</a>.intent.action.MAIN&quot; /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;
    &lt;/application&gt;

&lt;/manifest&gt;

Removing the ” category android:name="android.intent.category.LAUNCHER" ” TAG from the “Androidmanifest.xml” removes the information about the default launcher activity of the Application. Without explicitly defining which activity to behave as the launcher Activity, the Android system can’t sort out the launcher activity of your Application. As a result the Android system does not list out the App inside the default apps list.

Once you remove the TAG from the “Androidmanifest.xml” file, you can export it straightly into a virtual device via ADB commands. You will have to create the APK of the project and manually y copy them to your device storage and then install them.

android studio screenshot with build menu choosen and the Build APK option selected techusall

You can get the compiled APK from the “ProjectDirectory-Folder\app\build\outputs\apk” folder. The main disadvantage of the above method is that the Application is install just the way a service is installed and is not Called even for at least once after the installation.

Disabling the main Activity Class using the package manager.

This method is one of the best way to get the best result. Unlike the method shown in the above section, this method invokes the Application once after the installation of the Application.
The below shown codes are to be implemented inside the “onCreate()” method of your main activity.

PackageManager p = getPackageManager(); //Accessing the package manager
ComponentName componentName = new ComponentName(this, com.package.AppName.homeActivity.class);
/* Activity which is declare as [android:name="android.intent.category.LAUNCHER"] in the Manifest File*/
p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);  //Disable the Activity without Killing

What the code does is, with the help of the package manager the main activity of our Application is disabled without killing it. The App only executes for the first time and when the above code is executed from the  “onCreate()” function body, the package removes the activity and this the Launcher icon of the Application. Since the App is executed once, you can start any Broadcast receiving services or other services to do what ever you wish without having the Launcher icon inside the System App list.

It you are having any issues or doubts , please feel free to comment it out below in the discussion section. 🙂

Read More :