How to intercept a hard key pressed in a service?

前端 未结 2 669
遇见更好的自我
遇见更好的自我 2021-01-14 22:36

Is there anyway to intercept that a hard key was pressed by using a service in order to launch an activity?

In other words : Is it possible to handle the KeyEvents i

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-14 22:52

    Yes. You can capture KeyEvents with an InputMethodService. The Hard-Keys have their own key codes, just like the Soft-Keys.

    Look at the SoftKeypad example that google made.

提交回复
热议问题