0

How to check the phone is locked or not in android?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Narendran
  • 27
  • 1
  • 6

1 Answers1

0

I attached the answer for finding the phone is locked or not, i declared the code below,

KeyguardManager km = (KeyguardManager)getSystemService(Context.KEYGUARD_SERVICE);
boolean locked = km.inKeyguardRestrictedInputMode();
if(locked == true){
  // do something
}else{
  // do something else
}
Gerald Schneider
  • 17,416
  • 9
  • 60
  • 78
Narendran
  • 27
  • 1
  • 6
  • Direct answer from here http://stackoverflow.com/questions/9002032/how-to-find-the-screen-is-locked-in-android – AxeManTOBO Jun 13 '16 at 10:26