Android - Listener for hard keys press at background
问题 Android provides some callback methods which help our to handle key event inside the apps. But what if I want to listen key events when my app is running at background? Eg. I want to listen for long press event on search button to do a special feature. 回答1: KeyEvents can only be handled by Activities as they are the interface to the user pressing the keys and only when they are in the foreground. Even Services that run in the background are not intended to react on user input. But by using a