Android examples for Android OS:Device
is Device Sleeping
import android.app.KeyguardManager; import android.content.Context; public class Main { public static boolean isSleeping(Context context) { KeyguardManager kgMgr = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); return kgMgr.inKeyguardRestrictedInputMode(); }/* w w w . ja va 2s .co m*/ }