How visible / invisible launcher icon in android?

I am creating an application in which I need to hide the start icon and show the start icon on demand. I used the code below to hide the startup icon.

<category android:name="android.intent.category.LAUNCHER" /> // Remove this line from manifest.xml 

or

 PackageManager p = getPackageManager(); p.setComponentEnabledSetting(getComponentName(), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); 

Using this piece of code, I can only hide the application icon.

To show that I used this piece of code

 PackageManager p = getPackageManager(); p.setComponentEnabledSetting(getComponentName(), PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, PackageManager.DONT_KILL_APP); 

and

 PackageManager p = getPackageManager(); p.setComponentEnabledSetting(getComponentName(), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); 

But none of them work, or I can’t program the program to run back. Please suggest me how I can achieve this.

Thanks in advance

+7
android eclipse android-layout android-package-managers
source share
1 answer

try the following:

1. Change the MainActivity section in AndroidManifest.xml, delete the line with the main category in the intent filter section from it

 <category android:name="android.intent.category.LAUNCHER" />//DELETE THIS LINE 

Create <activity-alias> for your application, for each of your icons. Like this

 <activity-alias android:label="@string/app_name" android:icon="@drawable/icon" android:name=".MainActivity" android:enabled="false" android:targetActivity=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity-alias> 

Set program mode on or off

+3
source share

All Articles