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..
精彩评论