Example usage for android.app KeyguardManager isKeyguardLocked

List of usage examples for android.app KeyguardManager isKeyguardLocked

Introduction

In this page you can find the example usage for android.app KeyguardManager isKeyguardLocked.

Prototype

public boolean isKeyguardLocked() 

Source Link

Document

Return whether the keyguard is currently locked.

Usage

From source file:Main.java

public static boolean isScreenLocked(Context context) {
    KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
    return keyguardManager.isKeyguardLocked();
}

From source file:Main.java

/**
 * Return whether the keyguard requires a password to unlock and may
 * have any privacy restrictions./*from  w  ww.j ava2s.com*/
 */
public static boolean isSecure(@NonNull Context context) {
    KeyguardManager km = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
    return km.isKeyguardSecure() && km.isKeyguardLocked();
}