I need perform some action on press of home key like starting activity when some one presses the home key...how to do it?
Asked
Active
Viewed 969 times
0
-
Actually i need to perform some actions on the press of home button... Like i need to call a Log out API for my Application... As users will be online in my application and i want users to logout on press of home key when application goes at backgroud... CAn u help me out on this? – coderslay Apr 20 '11 at 04:18
-
possible duplicate of [Android - Is It possible to disable the click of home button](http://stackoverflow.com/questions/2162182/android-is-it-possible-to-disable-the-click-of-home-button) – Michael Petrotta Apr 20 '11 at 04:27
-
I need to perform some action on press of home key...thts it.... – coderslay Apr 20 '11 at 04:38
-
Then write your own home screen. – CommonsWare Apr 20 '11 at 12:03
-
See SO answers here, here and here. – Lars Blumberg Apr 20 '11 at 04:17
1 Answers
2
If what you really want is to perform some actions when your activity leaves the foreground, see the activity lifecycle. Your activity will have its onPause
method called when it is no longer in the foreground, and onStop
called when it is no longer visible.

adamp
- 28,862
- 9
- 81
- 69