Android - Activation of the system key lock (aka lock screen)

前端 未结 5 2127
借酒劲吻你
借酒劲吻你 2020-12-31 12:33

I have to activate android\'s system key lock (the one you get when you press the power off/hang up button). See here:

5条回答
  •  情歌与酒
    2020-12-31 13:18

    There's a pretty good example here:

    http://www.anddev.org/throwing-simulating_keystrokes_programatically-t717.html

    It looks like you can programmatically cause any keystroke to be sent to the system. It sounds like the keycode you're looking for is the KEYCODE_ENDCALL, but if that doesn't work there are plenty of other codes to try here:

    http://developer.android.com/reference/android/view/KeyEvent.html

    I don't know if there's any API call to cause the lock to occur, but this seems like a pretty sturdy workaround until you find a better solution.

提交回复
热议问题