Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to visible/invisible launcher icon in android?

I am creating an application in which i need to hide icon launcher and show icon launcher on request. I used below code to hide launcher 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);

By using these snippet of code, I am only able to hide application icon.

In order to show i used these code snippet

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 is effecting or i am not able to retrieve launcher icon back programmatically. Please suggest me how can i achieve this task.

Thanks in advance

like image 535
Vijay Kumar Avatar asked Nov 19 '13 05:11

Vijay Kumar


People also ask

Where is my launcher icon Android?

The user opens the Launcher by touching the icon at the bottom of the Home screen.

How hide installed apps in Android programmatically?

Hide app's icon using below code: PackageManager p = getPackageManager(); ComponentName componentName = new ComponentName(this, com. apps. MainActivity.


1 Answers

try this :

1 . Modify your MainActivity section in AndroidManifest.xml, delete from it, line with MAIN category in intent-filter section

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

Create <activity-alias> for your app, 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 programmatically enabled or disabled

like image 78
Harshit Rathi Avatar answered Oct 05 '22 04:10

Harshit Rathi