开发者

how to know which hardware key is pressed in a service?

I tried overriding InputMethodService.onKeyUp(开发者_如何转开发) and InputMethodService.onKeyDown() by extendingInputMethodService class but the methods are not called when you press the back , home , context menu ( basically the hard keys ) . What am i doing right ? is it the right approach ?


(Had an answer here befor but had missed that the question was about an service)

There is a simliar question about this topic here


You can use InputMethodService for listening the KeyEvents with onKeyDown(), onKeyLongpress() and onKeyUp(). The Hard-Keys have their own key codes, just like the Soft-Keys.

I am sure about the back key but i dont think the same case with home and recent buttons..

As for home and recent actions, InputMethodService will trigger the onfinishInput() and onfinishInputView() calls.So, may be we can do something..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜