I am trying to catch when the user has pressed the Home button. I thought I could use
protected void onResume()
{
registerReceiver(homeReceiver, new Inte
An easiest way is to put a boolean variable at false when you exit from that activity to go in some other activity. Then put the variable at true in the onResume method. Check in the method onStop() if it is not false, so if it is true then the Home button is pressed.
Something like:
boolean exit=false;
...
//wherever other activity starting
exit=false;
startActivity(activity);
...
@Override
protected void onResume() {
super.onResume();
exit=true;
}
...
@Override
protected void onStop() {
super.onStop();
if(exit){
//Home button is pressed
}
}