Hide installed app in android

Deadly 提交于 2020-02-03 00:37:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!