How can i stop services which is running on background. Is there any way to do it using Back and home button press
I have tried to do it using key events but still it's not working. Here you can check my code below ...
@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);
}
Help me with this or suggest me other option to stop service?