I'm trying to create an application in which the user can override the default behavior of the volume up / down buttons (as well as the screen on / off buttons - is this possible?). In any case, using some code in the lines of the following, I can do this:
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { super.onKeyUp(keyCode, event); if ((keyCode == KeyEvent.KEYCODE_VOLUME_UP)) { //this is where I can do my stuff return true; //because I handled the event } return false; //otherwise the system can handle it
}
But I would like it to be possible even when the application is not open, so I would like to set up a broadcast receiver or perhaps use something in the service to make this possible.
Thanks for any help.
source share