I know Screen Lock inclue None, Swipe,Pattern,Password and PIN.
I have read the docment How can i set up screen lock with a password programmatically?
I don't know what kind of lock type the following code apply to.
I have test the following code using different phones, it seems that sometimes the code apply to Password lock, and sometimes the code apply to PIN lock, I don't know why?
DevicePolicyManager devicePolicyManager =(DevicePolicyManager)getApplicationContext().getSystemService(Context.DEVICE_POLICY_SERVICE);
ComponentName demoDeviceAdmin =new ComponentName(this, MyAdmin.class);
devicePolicyManager.setPasswordQuality(demoDeviceAdmin,DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
devicePolicyManager.setPasswordMinimumLength(demoDeviceAdmin, 5);
boolean result = devicePolicyManager.resetPassword("123456", DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY);
Toast.makeText(this, "button_lock_password_device..."+result, Toast.LENGTH_LONG).show();