KeyguardManager mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
if (mKeyguardManager.inKeyguardRestrictedInputMode()) {
// keyguard on
}
if (mKeyguardManager.inKeyguardRestrictedInputMode()) {
// keyguard on
}