Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.app.KeyguardManager;

import android.content.Context;

import android.os.PowerManager;

public class Main {
    private static boolean isScreenOffOrLocked(Context context) {
        KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
        PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        boolean off = !powerManager.isScreenOn();
        off |= keyguardManager.inKeyguardRestrictedInputMode();
        return off;
    }
}