3

I was able to implement locking and unlocking of Screen-Lock programmatically. But I was wondering if its possible to change the mode of Screen-Lock say from 'slide' to 'pattern' or 'password' programmatically.

I searched the net but could'nt find anything, all results were about the usual locking and unlocking which I have already done.

Can any1 tell me if its possible ? If yes then how shall I achieve it.

Any help will be appreciated :) Thanks in advance :)

ik024
  • 3,566
  • 7
  • 38
  • 61

1 Answers1

4

You can use Device Administration API. And DeviceAdminSample is a good start.

There are following types you can set using setPasswordQuality()

        DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED,
        DevicePolicyManager.PASSWORD_QUALITY_SOMETHING,
        DevicePolicyManager.PASSWORD_QUALITY_NUMERIC,
        DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC,
        DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC,
        DevicePolicyManager.PASSWORD_QUALITY_COMPLEX

There are several answers on SO

Community
  • 1
  • 1
Pankaj Kumar
  • 81,967
  • 29
  • 167
  • 186
  • Thanks for ur reply :) But what if my default Sceen-Lock is 'Slide' one? Will it work then ? For Eg I usually open my phone by slide lock, but I want it to change to pattern lock or password lock from my app. – ik024 Mar 27 '14 at 12:01
  • ok thanks I will try it out now. I believe I can do the same thing for pattern lock also, right ? – ik024 Mar 27 '14 at 12:05
  • Yes you can. I think for that PASSWORD_QUALITY_SOMETHING is used. – Pankaj Kumar Mar 27 '14 at 12:07