bsimic
bsimic

Reputation: 926

How do I access the password type settings of an Android device?

I'm trying to access my devices password type settings and am getting a SettingNotFoundException even though the device does have a lock PIN set.

I have tried using the LockPatternUtils suggested in this question here but it does not work.

Here is basically what I'm doing (and what LockPatternUtils does):

    try {
        result = android.provider.Settings.Secure.getLong(
                mContentResolver, "lockscreen.password_type");
    } catch (SettingNotFoundException e) {
        Log.d("Cannot get key", "cannot get long value", e);
    }

This is where the SettingNotFoundException occurs since it obviously cannot find that setting.

Here is the kicker. I'm testing this on 2 different devices. One has a password of 6 characters and the other has a PIN of 4 characters. The first has Android 4.1.2 and the other 4.2.1. It works fine on the first one that's running on 4.1.2

Thank you!

Upvotes: 0

Views: 1480

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006564

You are welcome to get information about password quality and such via DevicePolicyManager and the device admin APIs.

Upvotes: 1

Related Questions