Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android hide/unhide app icon programmatically

i had used below code for hide app icon programmatically

try{     PackageManager p = getPackageManager();     p.setComponentEnabledSetting(getComponentName(), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); }catch (Exception e) {     e.printStackTrace(); } 

Now I want to make icon visible programmatically

like image 766
PankajAndroid Avatar asked Oct 01 '13 10:10

PankajAndroid


People also ask

How to hide app icons on Android?

How to Hide App Icons on Android 1 Open your app drawer. On most phones it’s the button on the center of your screen named "Apps.". Select Your App Drawer. 2 Go to your home screen settings. 3 Tap hide apps. 4 Select the app icons you want to hide. See More....

How do I hide apps on my Samsung Galaxy device?

Tap the “ Menu ” button on the screen and select “ Settings .” Step 3: Tap hide apps. Check the corresponding boxes for the app icons you want to hide.

How do I delete app icons from my Android home screen?

On most phones, you can delete app icons from the home screen without deleting the apps itself. But you can also hide apps on Android devices directly via the app drawer. On most phones it’s the button on the center of your screen named “Apps.” Tap the “ Menu ” button on the screen and select “ Settings .”

How to change app icon dynamically in Android Studio?

Then as per the user type, we can change the App Icon Dynamically. To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Java as the programming language. Navigate to the app > res > layout > activity_main.xml and add the below code to that file.


2 Answers

Hide app's icon using below code:

PackageManager p = getPackageManager(); ComponentName componentName = new ComponentName(this, com.apps.MainActivity.class); // activity which is first time open in manifiest file which is declare as <category android:name="android.intent.category.LAUNCHER" /> p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); 

Here is how to bring back the app's icon.

PackageManager p = getPackageManager(); ComponentName componentName = new ComponentName(this, com.apps.MainActivity.class); p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); 

Important Edit:

According to docs, as of Android Q (API 29) all app icons will be visible in the launcher no matter what unless:

As of Android Q, at least one of the app's activities or synthesized activities appears in the returned list unless the app satisfies at least one of the following conditions:

  • The app is a system app.
  • The app doesn't request any permissions.
  • The tag in the app's manifest doesn't contain any child elements that represent app components.

Additionally, the system hides synthesized activities for some or all apps in the following enterprise-related cases:

  • If the device is a fully managed device, no synthesized activities for any app appear in the returned list.
  • If the current user has a work profile, no synthesized activities for the user's work apps appear in the returned list.
like image 64
CoronaPintu Avatar answered Sep 27 '22 20:09

CoronaPintu


Best Way To Hide Application Icon From Launcher You Can Use

<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>

In Your Manifest MainActivity

  <activity android:name=".MainActivity">         <intent-filter>             <action android:name="android.intent.action.MAIN" />             <category android:name="android.intent.category.LEANBACK_LAUNCHER"/>         </intent-filter>     </activity> 

also add uses-feature in Manifest Tag

<uses-feature     android:name="android.software.leanback"     android:required="true" /> 
like image 42
Sanjay Avatar answered Sep 27 '22 20:09

Sanjay