Share via


DevicePolicyManager.SetPasswordHistoryLength(ComponentName, Int32) Method

Definition

Called by an application that is administering the device to set the length of the password history.

[Android.Runtime.Register("setPasswordHistoryLength", "(Landroid/content/ComponentName;I)V", "GetSetPasswordHistoryLength_Landroid_content_ComponentName_IHandler")]
public virtual void SetPasswordHistoryLength (Android.Content.ComponentName admin, int length);
[<Android.Runtime.Register("setPasswordHistoryLength", "(Landroid/content/ComponentName;I)V", "GetSetPasswordHistoryLength_Landroid_content_ComponentName_IHandler")>]
abstract member SetPasswordHistoryLength : Android.Content.ComponentName * int -> unit
override this.SetPasswordHistoryLength : Android.Content.ComponentName * int -> unit

Parameters

admin
ComponentName

Which DeviceAdminReceiver this request is associated with.

length
Int32

The new desired length of password history. A value of 0 means there is no restriction.

Attributes

Remarks

Called by an application that is administering the device to set the length of the password history. After setting this, the user will not be able to enter a new password that is the same as any password in the history. Note that the current password will remain until the user has set a new one, so the change does not take place immediately. To prompt the user for a new password, use #ACTION_SET_NEW_PASSWORD or #ACTION_SET_NEW_PARENT_PROFILE_PASSWORD after setting this value.

On devices not supporting PackageManager#FEATURE_SECURE_LOCK_SCREEN feature, the password history length is always 0.

The calling device admin must have requested DeviceAdminInfo#USES_POLICY_LIMIT_PASSWORD to be able to call this method; if it has not, a security exception will be thrown.

This method can be called on the DevicePolicyManager instance returned by #getParentProfileInstance(ComponentName) in order to set restrictions on the parent profile.

Java documentation for android.app.admin.DevicePolicyManager.setPasswordHistoryLength(android.content.ComponentName, int).

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