1

i want to hide the installed app by another app in android application, lets say user has installed 3rd party app called Skype, Watsapp, facebook etc...

is there a way we can hide and show them upon click of a button from another app?. i tried below code. No luck, nothing happened to my launcher

 PackageManager packageManager = context.getPackageManager();
ComponentName componentName = new ComponentName(context,
        LauncherActivity.class);
packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
        PackageManager.DONT_KILL_APP);

But here i was not getting how to hide a particular application?, i also followed these SO link

but i could not get to know how to hide a perticular application.

Community
  • 1
  • 1
Naruto
  • 9,476
  • 37
  • 118
  • 201
  • That other link mentions that the icon might not be removed until a reboot. Is the icon still there after a reboot? – scottt Mar 31 '14 at 05:55
  • i cannt thing u can hide other apps becuse it's should be private nd when you hide in this way it will destroy that apps mainActivity so.. – PankajAndroid Mar 31 '14 at 05:58
  • @scottt Yes thats true, icon s still there... even after reboot – Naruto Mar 31 '14 at 06:06
  • but, how does samsung phones have option to hide installed app?? – Naruto Mar 31 '14 at 06:07
  • The launcher on Samsung phones is at least partially their own creation. They can make it do anything they want. In general, you'll find anything to do with creating, deleting, hiding home screen icons to be a bit (or a lot) manufacturer dependent. – scottt Mar 31 '14 at 06:13
  • Because Samsung use their own customized launcher, which they can add such feature to it. Edit: *ninja'd* – Andrew T. Mar 31 '14 at 06:13
  • ok, atleast can we do something like, show the icon in launcher but when user press we can return i.e do not launch, rather than hiding. Is there a way?. For eg, when you open messaging, catch the click event of Messaging app and simply return – Naruto Mar 31 '14 at 06:20
  • 1
    You are welcome to build your own home screen launcher, then convince users to use it. – CommonsWare Mar 31 '14 at 06:50

1 Answers1

4

To hide/unhide an app, your app need to be the DevicePolicyManager. You can find more information about the device policy manager at http://developer.android.com/reference/android/app/admin/DevicePolicyManager.html and you may need to use https://developer.android.com/reference/android/app/admin/DevicePolicyManager.html#setApplicationHidden(android.content.ComponentName,%20java.lang.String,%20boolean)

 DevicePolicyManager dpm =
            (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
 ComponentName ownerComponent = new ComponentName(context, DeviceAdminReceiverImpl.class);
 boolean newHiddenValue = true;
 dpm.setApplicationHidden(ownerComponent, packageName, newHiddenValue);
Yash
  • 3,438
  • 2
  • 17
  • 33
  • Yes, but you need Lollipop – Premier Mar 08 '15 at 12:32
  • this way won't work. because you must be the DeviceOwner application to do that in this way – alex_au Nov 06 '15 at 15:59
  • "Called by **profile or device owners** to hide or unhide packages. When a package is hidden it is unavailable for use, but the data and actual package file remain." – Dori Jul 28 '16 at 08:54
  • when i tried this api 'setApplicationHidden' , it always returns 'false' even though my app is a device owner. any idea? please look into this question http://stackoverflow.com/questions/40416030/hide-unhide-other-installed-apps-in-android – Raneez Ahmed Nov 05 '16 at 07:30