1

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();   
Community
  • 1
  • 1
HelloCW
  • 843
  • 22
  • 125
  • 310

1 Answers1

1

Depending on the value you pass as the first parameter in devicePolicyManager.resetPassword(), the Lock will either ask for PIN or Password.

// Screen Lock will act as PIN.
devicePolicyManager.resetPassword("123456", DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY);

// Screen Lock will act as Password.
devicePolicyManager.resetPassword("123abc", DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY);

So for alphanumeric = password

   numbers = pin

Hope it helps!!!

waqaslam
  • 67,549
  • 16
  • 165
  • 178
lifesoft
  • 21
  • 2