0

This code works and hides my application icon:

PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName("myPackageName", "MyLauncherClass"); 
p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

But I need hide another application icon.

When i replace myPackageName and MyLauncherClass with another application package name and launcher class, app force closed.

This means that i can hide my app icon only?

1 Answers1

1

This means that i can hide my app icon only?

Correct. There may be some options for doing this as a device owner app, but ordinary apps cannot disable other apps.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 1
    I was looking for a solution to make a program like " Hide Apps" But no need to be root permission. –  Jul 20 '16 at 14:14
  • 1
    @RezaMohammadi: Fortunately, that is not possible. You are welcome to write your own home screen, and in there allow users to "hide" and "show" apps from your launcher, where you hide and show the icons for those apps. That is as close as you can get without some form of superuser capability. – CommonsWare Jul 20 '16 at 14:17
  • 1
    Is there any possibility of hide icon with admin permission ? – Ahmad Dec 03 '20 at 08:24
  • 1
    @Ahmad: If by "admin permission" you mean being a device administrator, that used to not be enough. However, I have not worked with device administrators in a few years, so I may be forgetting something. – CommonsWare Dec 03 '20 at 13:36