DevicePolicyManager.SetUninstallBlocked Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Change whether a user can uninstall a package.
[Android.Runtime.Register("setUninstallBlocked", "(Landroid/content/ComponentName;Ljava/lang/String;Z)V", "GetSetUninstallBlocked_Landroid_content_ComponentName_Ljava_lang_String_ZHandler")]
[Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_APPS_CONTROL")]
public virtual void SetUninstallBlocked (Android.Content.ComponentName? admin, string? packageName, bool uninstallBlocked);
[<Android.Runtime.Register("setUninstallBlocked", "(Landroid/content/ComponentName;Ljava/lang/String;Z)V", "GetSetUninstallBlocked_Landroid_content_ComponentName_Ljava_lang_String_ZHandler")>]
[<Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_APPS_CONTROL")>]
abstract member SetUninstallBlocked : Android.Content.ComponentName * string * bool -> unit
override this.SetUninstallBlocked : Android.Content.ComponentName * string * bool -> unit
Parameters
- admin
- ComponentName
Which DeviceAdminReceiver
this request is associated with. Null if the
caller is not a device admin.
- packageName
- String
package to change.
- uninstallBlocked
- Boolean
true if the user shouldn't be able to uninstall the package.
- Attributes
Remarks
Change whether a user can uninstall a package. This function can be called by a device owner, profile owner, or by a delegate given the #DELEGATION_BLOCK_UNINSTALL
scope via #setDelegatedScopes
or holders of the permission android.Manifest.permission#MANAGE_DEVICE_POLICY_APPS_CONTROL
.
Starting from Build.VERSION_CODES#UPSIDE_DOWN_CAKE
, after the set uninstall blocked policy has been set, PolicyUpdateReceiver#onPolicySetResult(Context, String, Bundle, TargetUser, PolicyUpdateResult)
will notify the admin on whether the policy was successfully set or not. This callback will contain: <ul> <li> The policy identifier DevicePolicyIdentifiers#PACKAGE_UNINSTALL_BLOCKED_POLICY
<li> The additional policy params bundle, which contains PolicyUpdateReceiver#EXTRA_PACKAGE_NAME
the package name the policy applies to <li> The TargetUser
that this policy relates to <li> The PolicyUpdateResult
, which will be PolicyUpdateResult#RESULT_POLICY_SET
if the policy was successfully set or the reason the policy failed to be set (e.g. PolicyUpdateResult#RESULT_FAILURE_CONFLICTING_ADMIN_POLICY
) </ul> If there has been a change to the policy, PolicyUpdateReceiver#onPolicyChanged(Context, String, Bundle, TargetUser, PolicyUpdateResult)
will notify the admin of this change. This callback will contain the same parameters as PolicyUpdateReceiver#onPolicySetResult and the PolicyUpdateResult
will contain the reason why the policy changed.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.