Example usage for android.content Context KEYGUARD_SERVICE

List of usage examples for android.content Context KEYGUARD_SERVICE

Introduction

In this page you can find the example usage for android.content Context KEYGUARD_SERVICE.

Prototype

String KEYGUARD_SERVICE

To view the source code for android.content Context KEYGUARD_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.app.KeyguardManager for controlling keyguard.

Usage

From source file:org.cryptsecure.Utility.java

/**
 * Checks if is screen locked.//w ww. j  a  v  a 2s.c  o  m
 * 
 * @param context
 *            the context
 * @return true, if is screen locked
 */
public static boolean isScreenLocked(Context context) {
    KeyguardManager myKM = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
    if (myKM.inKeyguardRestrictedInputMode()) {
        // it is locked
        return true;
    } else {
        // it is not locked
        return false;
    }
}

From source file:com.sentaroh.android.SMBSync.SMBSyncMain.java

static final private boolean isKeyguardEffective(Context mContext) {
    KeyguardManager keyguardMgr = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
    boolean result = keyguardMgr.inKeyguardRestrictedInputMode();
    return result;
}