Compartilhar via


DevicePolicyManager.SetAccountManagementDisabled Method

Definition

Called by a device owner or profile owner to disable account management for a specific type of account.

[Android.Runtime.Register("setAccountManagementDisabled", "(Landroid/content/ComponentName;Ljava/lang/String;Z)V", "GetSetAccountManagementDisabled_Landroid_content_ComponentName_Ljava_lang_String_ZHandler")]
[Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_ACCOUNT_MANAGEMENT")]
public virtual void SetAccountManagementDisabled (Android.Content.ComponentName? admin, string? accountType, bool disabled);
[<Android.Runtime.Register("setAccountManagementDisabled", "(Landroid/content/ComponentName;Ljava/lang/String;Z)V", "GetSetAccountManagementDisabled_Landroid_content_ComponentName_Ljava_lang_String_ZHandler")>]
[<Android.Runtime.RequiresPermission("android.permission.MANAGE_DEVICE_POLICY_ACCOUNT_MANAGEMENT")>]
abstract member SetAccountManagementDisabled : Android.Content.ComponentName * string * bool -> unit
override this.SetAccountManagementDisabled : 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.

accountType
String

For which account management is disabled or enabled.

disabled
Boolean

The boolean indicating that account management will be disabled (true) or enabled (false).

Attributes

Remarks

Called by a device owner or profile owner to disable account management for a specific type of account.

The calling device admin must be a device owner or profile owner. If it is not, a security exception will be thrown.

When account management is disabled for an account type, adding or removing an account of that type will not be possible.

From android.os.Build.VERSION_CODES#N the profile or device owner can still use android.accounts.AccountManager APIs to add or remove accounts when account management for a specific type is disabled.

This method may be called on the DevicePolicyManager instance returned from #getParentProfileInstance(ComponentName) by the profile owner on an organization-owned device, to restrict accounts that may not be managed on the primary profile.

Starting from Build.VERSION_CODES#UPSIDE_DOWN_CAKE, after the account management disabled 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#ACCOUNT_MANAGEMENT_DISABLED_POLICY<li> The additional policy params bundle, which contains PolicyUpdateReceiver#EXTRA_ACCOUNT_TYPE the account type 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.setAccountManagementDisabled(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