Search code examples
androidlockingmodescreen-lock

Programmatically changing ScreenLock mode from "Slide" to "Pattern" Android


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 :)


Solution

  • 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