title: KeyCode, KeyEvent Not working
body: <p>How can i stop services which is running on background.
  Is there any way to do it using Back and home button press </p>
  
  <p>I have tried to do it using key events but still it's not working. Here you can check my code  below ...</p>
  
  <pre><code>@Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
      if ((keyCode == KeyEvent.KEYCODE_HOME)) {          
          stopBackgroundAudio();// background services 
          return true;
      }
      if ((keyCode == KeyEvent.KEYCODE_BACK)) {           
          stopBackgroundAudio();
          return true;
      }
      if ((keyCode == KeyEvent.KEYCODE_MENU)) {            
          stopBackgroundAudio();
          return true;
      }
       return super.onKeyDown(keyCode, event);
  
  }
  </code></pre>
  
  <p>Help me with this or suggest me other option to stop service?</p>