Is there a way to know if onUserLeaveHint is caused due to Home Button or some new intent?
Asked
Active
Viewed 1,305 times
2 Answers
0
As is stated at this question, the call is made if one of the following conditions happen.
- The user presses the back button.
- The user presses the home button.
- 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
-
There are ways, but not using onUserLeaveHint. I'll edit my answer appropriately. – PearsonArtPhoto Nov 27 '12 at 11:44
-
Yes back is easy... what about number 3 – Chen Kinnrot Nov 27 '12 at 15:11
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