问题
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.
回答1:
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);
来源:https://stackoverflow.com/questions/22754398/hide-installed-app-in-android