Udostępnij za pośrednictwem


DevicePolicyManager.SetPasswordMinimumLength(ComponentName, Int32) Method

Definition

Called by an application that is administering the device to set the minimum allowed password length.

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

Parameters

admin
ComponentName

Which DeviceAdminReceiver this request is associated with.

length
Int32

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

Attributes

Remarks

Called by an application that is administering the device to set the minimum allowed password length. After setting this, the user will not be able to enter a new password that is not at least as restrictive as what has been set. 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. This constraint is only imposed if the administrator has also requested either #PASSWORD_QUALITY_NUMERIC , #PASSWORD_QUALITY_NUMERIC_COMPLEX, #PASSWORD_QUALITY_ALPHABETIC, #PASSWORD_QUALITY_ALPHANUMERIC, or #PASSWORD_QUALITY_COMPLEX with #setPasswordQuality. If an app targeting SDK level android.os.Build.VERSION_CODES#R and above enforces this constraint without settings password quality to one of these values first, this method will throw IllegalStateException.

On devices not supporting PackageManager#FEATURE_SECURE_LOCK_SCREEN feature, the password is always treated as empty.

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.

Apps targeting android.os.Build.VERSION_CODES#R and below can call this method on the DevicePolicyManager instance returned by #getParentProfileInstance(ComponentName) in order to set restrictions on the parent profile.

<string>Note:</strong> this method is ignored on {PackageManager#FEATURE_AUTOMOTIVE automotive builds}.

This member is deprecated. see #setPasswordQuality(ComponentName, int) for details.

Java documentation for android.app.admin.DevicePolicyManager.setPasswordMinimumLength(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