DUPLICATE WARNING : this post does NOT touch the on / off screen , this post is a keypad lock (these problems do not match).
Fortunately, there is a direct situation where keyguard is unlocked, but what about the event when the key lock is locked? I searched the list of Android API events back and forth and I just donโt see it (the phrase โlockโ is not, the phrase โkeyguardโ is one, for the status is โoffโ).
I know a workaround - wait for the event with the screen turned off, check the lock status of the keyboard in a cycle and wait for the event to appear on the screen, because the phone can work in only two directions, starting from the screen - either the phone will be locked or the screen will turn on again. Not a huge amount of code, but hack anyway, so I hope that something is missing in the manual, and there is a direct event to lock the keypad lock.
source share