我想在应用程序中隐藏一些应用程序图标。这是我的代码,但它不起作用:
PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName("com.test.android.app", "com.test.android.app.launcher homeactivity");
p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
logcat的:
FATAL EXCEPTION: Thread-24452
java.lang.SecurityException: Permission Denial: attempt to change component state from pid=19832, uid=10158, package uid=10143
at android.os.Parcel.readException(Parcel.java:1425)
at android.os.Parcel.readException(Parcel.java:1379)
at android.content.pm.IPackageManager$Stub$Proxy.setComponentEnabledSetting(IPackageManager.java:2573)
at android.app.ApplicationPackageManager.setComponentEnabledSetting(ApplicationPackageManager.java:1250)
at com.example.dashboard.MainActivity.getAllpackages(MainActivity.java:169)
at com.example.dashboard.MainActivity.initListview(MainActivity.java:77)
at com.example.dashboard.MainActivity.access$0(MainActivity.java:76)
at com.example.dashboard.MainActivity$1.run(MainActivity.java:66)
at java.lang.Thread.run(Thread.java:838)
答案 0 :(得分:0)
在manifest.xml中,您将添加
<permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE"/>
android:sharedUserId="android.uid.system"
在Android.mk将添加
LOCAL_CERTIFICATE := platform