DevicePolicyManager.IsUninstallBlocked(ComponentName, String) Method

Definition

Check whether the user has been blocked by device policy from uninstalling a package.

[Android.Runtime.Register("isUninstallBlocked", "(Landroid/content/ComponentName;Ljava/lang/String;)Z", "GetIsUninstallBlocked_Landroid_content_ComponentName_Ljava_lang_String_Handler")]
public virtual bool IsUninstallBlocked (Android.Content.ComponentName? admin, string? packageName);
[<Android.Runtime.Register("isUninstallBlocked", "(Landroid/content/ComponentName;Ljava/lang/String;)Z", "GetIsUninstallBlocked_Landroid_content_ComponentName_Ljava_lang_String_Handler")>]
abstract member IsUninstallBlocked : Android.Content.ComponentName * string -> bool
override this.IsUninstallBlocked : Android.Content.ComponentName * string -> bool

Parameters

admin
ComponentName

The name of the admin component whose blocking policy will be checked, or null to check whether any admin has blocked the uninstallation. Starting from android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE admin will be ignored and assumed null.

packageName
String

package to check.

Returns

true if uninstallation is blocked and the given package is visible to you, false otherwise if uninstallation isn't blocked or the given package isn't visible to you.

Attributes

Remarks

Check whether the user has been blocked by device policy from uninstalling a package. Requires the caller to be the profile owner if checking a specific admin's policy.

<strong>Note:</strong> Starting from android.os.Build.VERSION_CODES#LOLLIPOP_MR1, the behavior of this API is changed such that passing null as the admin parameter will return if any admin has blocked the uninstallation. Before L MR1, passing null will cause a NullPointerException to be raised.

<strong>Note:</strong> If your app targets Android 11 (API level 30) or higher, this method returns a filtered result. Learn more about how to manage package visibility.

Starting from Build.VERSION_CODES#UPSIDE_DOWN_CAKE, the returned policy will be the current resolved policy rather than the policy set by the calling admin.

Java documentation for android.app.admin.DevicePolicyManager.isUninstallBlocked(android.content.ComponentName, java.lang.String).

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.

Applies to