1

Is there a way to know if onUserLeaveHint is caused due to Home Button or some new intent?

Chen Kinnrot
  • 20,609
  • 17
  • 79
  • 141

2 Answers2

0

As is stated at this question, the call is made if one of the following conditions happen.

  1. The user presses the back button.
  2. The user presses the home button.
  3. The user hits the announciator bar.

If you want to tell a back pressed from a home pressed, you set an onBackPressed sequence, by adding the appropriate function to your activity:

void onBackPressed(){
  //Do Something
}
Community
  • 1
  • 1
PearsonArtPhoto
  • 38,970
  • 17
  • 111
  • 142
0

You need to cache all possible events that may make the user leave the activity, like new intents to outer apps, and when user leave hint occur check if one of this events occured before, if so, it's not the home button, if not, and you track the back, than it's the home button.

Chen Kinnrot
  • 20,609
  • 17
  • 79
  • 141