Language

DevicePolicyManager.SetPolicy Method

Definition

Sets the given policy.

[Android.Runtime.Register("setPolicy", "(Landroid/app/admin/PolicyIdentifier;ILjava/lang/Object;)V", "GetSetPolicy_Landroid_app_admin_PolicyIdentifier_ILjava_lang_Object_Handler", ApiSince=37)]
[Java.Interop.JavaTypeParameters(new System.String[] { "T" })]
public virtual void SetPolicy(Android.App.Admin.PolicyIdentifier id, Android.App.Admin.DevicePolicyManagerScope scope, Java.Lang.Object? value);
[<Android.Runtime.Register("setPolicy", "(Landroid/app/admin/PolicyIdentifier;ILjava/lang/Object;)V", "GetSetPolicy_Landroid_app_admin_PolicyIdentifier_ILjava_lang_Object_Handler", ApiSince=37)>]
[<Java.Interop.JavaTypeParameters(new System.String[] { "T" })>]
abstract member SetPolicy : Android.App.Admin.PolicyIdentifier * Android.App.Admin.DevicePolicyManagerScope * Java.Lang.Object -> unit
override this.SetPolicy : Android.App.Admin.PolicyIdentifier * Android.App.Admin.DevicePolicyManagerScope * Java.Lang.Object -> unit

Parameters

id
PolicyIdentifier

The identifier of the policy to set. See android.app.admin.policies for available policy identifiers.

scope
DevicePolicyManagerScope

The scope the policy will apply to.

value
Object

The value of the policy. If value is set to null, the policy is cleared. Check the documentation of individual identifiers for more details.

Attributes

Remarks

Sets the given policy.

Use getPolicy(PolicyIdentifier, int) to read back the value.

Use getResolvedDeviceWidePolicy(PolicyIdentifier) or getResolvedPerUserPolicy(PolicyIdentifier) to get the resolved policy value used on the device. The returned value can differ from the value set by the caller. The resolved value is the value that is currently being enforced on the device after conflict resolution has been performed between all the policies set by all admins at all active scopes.

Android reference for android.app.admin.DevicePolicyManager.setPolicy.

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