How to lock Android screen via ADB?

Cool, I just found KEYCODE_POWER which is 26.

so it works by sending:

adb shell input keyevent 26

which locks the screen if the screen is unlocked. If the screen is already locked, it wakes up the device.

My guess is that the only way to ensure that the screen is locked (off), is to unlock (we use keyevent 82 (menu), then lock it with the power button keyevent. Does anyone have any idea if this is true?

Leave a Comment