DevicePolicyManager.SetApplicationHidden Method

Definition

Hide or unhide packages.

[Android.Runtime.Register("setApplicationHidden", "(Landroid/content/ComponentName;Ljava/lang/String;Z)Z", "GetSetApplicationHidden_Landroid_content_ComponentName_Ljava_lang_String_ZHandler")]
[Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_PACKAGE_STATE")]
public virtual bool SetApplicationHidden (Android.Content.ComponentName? admin, string? packageName, bool hidden);
[<Android.Runtime.Register("setApplicationHidden", "(Landroid/content/ComponentName;Ljava/lang/String;Z)Z", "GetSetApplicationHidden_Landroid_content_ComponentName_Ljava_lang_String_ZHandler")>]
[<Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_PACKAGE_STATE")>]
abstract member SetApplicationHidden : Android.Content.ComponentName * string * bool -> bool
override this.SetApplicationHidden : Android.Content.ComponentName * string * bool -> bool

Parameters

admin
ComponentName

Which DeviceAdminReceiver this request is associated with, or null if the caller is not a device admin.

packageName
String

The name of the package to hide or unhide.

hidden
Boolean

true if the package should be hidden, false if it should be unhidden.

Returns

boolean Whether the hidden setting of the package was successfully updated.

Attributes

Remarks

Hide or unhide packages. When a package is hidden it is unavailable for use, but the data and actual package file remain. This function can be called by a device owner, profile owner, or by a delegate given the #DELEGATION_PACKAGE_ACCESS scope via #setDelegatedScopes.

This method can be called on the DevicePolicyManager instance, returned by #getParentProfileInstance(ComponentName), where the caller must be the profile owner of an organization-owned managed profile and the package must be a system package. If called on the parent instance, then the package is hidden or unhidden in the personal profile.

Starting from Build.VERSION_CODES#UPSIDE_DOWN_CAKE, after the application hidden 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#APPLICATION_HIDDEN_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.

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

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