javaandroidandroid-launcher

hide application launcher icon


I have 3 Apps A , B , C and I want to Hide icons of A & B from launcher . and I want to run A & B inside of C .

I Found this code for Hide apps :

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

I found this cod for run app inside other apps :

  try {
                    PackageManager packageManager = getPackageManager();
                    Intent intent = packageManager.getLaunchIntentForPackage("ir.alexandre9009.nothing");
                    if (null != intent) {
                        startActivity(intent);
                    }
                } catch (ActivityNotFoundException e) {
                    // default message
                } catch (Exception e) {
                    // default message
                }

Both codes work correctly

But when I use both of them at the same time, they do not work. That is, when I hide the A and B software icons, they can no longer be implemented from within C software

I want to hide software A and B and run them from within the software C to launch their activity.


Solution

  • Hide app's icon:

    PackageManager p = getPackageManager();
    ComponentName componentName = new ComponentName(this, your hiding app launcher class *com.A.MainActivity.class*); 
    p.setComponentEnabledSetting(componentName, 
                                PackageManager.COMPONENT_ENABLED_STATE_DISABLE, 
                                  PackageManager.DONT_KILL_APP);
    

    Bring back app's icon:

    PackageManager p = getPackageManager();
    ComponentName componentName = new ComponentName(this, your bring back app launcher class *com.A.MainActivity.class*);
    p.setComponentEnabledSetting(componentName, 
    PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);