is Screen Locked - Android User Interface

Android examples for User Interface:Screen Lock

Description

is Screen Locked

Demo Code


//package com.java2s;

import android.app.KeyguardManager;
import android.content.Context;

import android.os.PowerManager;

public class Main {

    public static boolean isScreenLocked(Context context) {
        KeyguardManager mKeyguardManager = (KeyguardManager) context
                .getSystemService(Context.KEYGUARD_SERVICE);
        PowerManager pm = (PowerManager) context
                .getSystemService(Context.POWER_SERVICE);
        if (pm.isScreenOn() == false) {
            return true;
        } else {// w w  w  . j a va2s. c o m
            return mKeyguardManager.inKeyguardRestrictedInputMode();
        }
    }
}

Related Tutorials