I have a method that stop the my app ringing tone.
CommonUtils.pauseAlarm();
and i want to apply these methods on Device home button click but it does not get home button click event.
All key event detect like menu,up, down button click but not get home button click
if ((keyCode == KeyEvent.KEYCODE_HOME)) {
CommonUtils.pauseAlarm();// background services
return true;
}
I have search many sites, some sites give the solution like
@Override
protected void onUserLeaveHint() {
Log.d("onUserLeaveHint", "Home button pressed");
CommonUtils.pauseMusic();
super.onUserLeaveHint();
}
Also i am try this function
@Override
public void onPause(){
super.onPause();
CommonUtils.pauseMusic();
}
but those method also call on my app another button click event So please give me any idea? What i am doing wrong.