Android Question tracking Keyevents from a service


Licensed User
I am well aware that keyevents cannot be tracked from a service due to security reasons. At least this is true what regards the edit-text and soft keyboard I think.

However, I have read that some hardware buttons such as Volume can be detected from a service. I am in the need to detect the keyevent and the keycode from a TV Remote Control in a service. Using Activity_KeyPress (in an activity of course) I have managed to get most keycodes necessary. I am not sure but perhaps d-pad constants and other hardware-buttons can also work with a service? At least I would like to try and thus I am wondering what code I would need to write to get the keyevent in a service?

Any help would be appreciated.

Edit: perhaps the BroadcastReceiver-library can be used for this purpose?
Last edited: