title: Android capturing volume up/down key presses in broadcast receiver?
body: <p>I'm trying to make an application where the user can override the default behaviour of the volume up/down buttons (as well as the screen on/off button - is this possible?). Anyways, using some code along the lines of the following I can do this: </p>
  
  <pre><code>@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        
  </code></pre>
  
  <p>}</p>
  
  <p>But I would like it to be possible even when the application is not open, hence why I'd like to set up a broadcast receiver or maybe stick something in a service to make this possible. </p>
  
  <p>Thanks for any help. </p>