How to reveal that screen is locked?

后端 未结 3 2138
日久生厌
日久生厌 2020-12-28 10:35

In my application I need to know when device is locked (on HTC\'s it looks like short press on \"power\" button). So the question is: which event is triggered when device is

3条回答
  •  不思量自难忘°
    2020-12-28 10:52

    There is a better way:

    KeyguardManager myKM = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
    if( myKM.inKeyguardRestrictedInputMode()) {
     //it is locked
    } else {
     //it is not locked
    }
    

提交回复
热议问题