I have read the documnet How can i set up screen lock with a password programmatically?.
I can set a password to lock the screen programmatically using the following code.
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()
How can I cancel screen lock with a password programmatically? Could you help me?
And more, how can I set up screen lock with a PIN programmatically? Thanks!