Reputation: 704
I'm trying to hide another application by using the following code:
PackageManager pm = this.getPackageManager();
pm.setComponentEnabledSetting(new ComponentName("com.sas.remotesample",".Player"),
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT, PackageManager.DONT_KILL_APP);
and with the following permission:
<uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE"/>
but it throws
java.lang.SecurityException: Permission Denial: attempt to change component state
Upvotes: 0
Views: 197
Reputation: 1006539
CHANGE_COMPONENT_ENABLED_STATE
has a protectionLevel
of signature|privileged
. This means that either:
You have to build your own custom ROM, then sign your app with the same signing key that you used to sign your custom ROM. Then, devices with your custom ROM installed will allow your app to control component states of other apps.
Your app has to be pushed to the system partition on rooted devices by their users.
Otherwise, you cannot hold this permission. Or, as the documentation for the permission states, "Not for use by third-party applications".
Upvotes: 1