Android examples for Phone:Screen
is Screen Off Or Locked
//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; }/*from w w w.ja v a2s . c o m*/ }