h6. What We should expose a function that allows the end developer to check if the underlying device has a lock screen enabled.
h6. Why Adding a lock screen a lock screen enhances device security and is used as a seed for various encryption functions in Android. Providing a check to see if the device lock is set to and end developer will be a helpful feature.
h6. How We can use the Android KeyguardManager class to check if the device has a lock screen set.
{code:java} /** * Detect if the device has a lock screen setup (pin, password etc). */ public void boolean detectDeviceLock() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(KEYGUARD_SERVICE); if (keyguardManager.isDeviceSecure()) { return true; } { return false; } } else { return false; } } {code}
*Note*: We should make a note in the docs that this is only available from Android M onwards. |
|