I want to detect home key press three times from home screen of android
such as after this want to perform event. Is there any way to detect home key press three times in android
.
Asked
Active
Viewed 1,719 times
0

Ajay S
- 48,003
- 27
- 91
- 111
-
this will help you http://stackoverflow.com/questions/10025660/override-home-and-back-button-is-case-a-boolean-is-true/10025904#10025904 – Mohammed Azharuddin Shaikh Nov 29 '12 at 10:33
-
This approach is no more working for latest versions. – Andro Selva Nov 29 '12 at 10:35
3 Answers
3
You have to this in the Android OS, PhoneWindowManager
, this is where the HOME button is handled.
To change that you have to change and build the AOSP. And flash this on you device. Therefore for app developers this is not possible.

RvdK
- 19,580
- 4
- 64
- 107
1
If homekey is pressed in the activity it will come to
@Override
protected void onUserLeaveHint() {
// TODO Auto-generated method stub
super.onUserLeaveHint();
}
put the counter and when it reached to 3 perform the action.

Dinesh Prajapati
- 9,274
- 5
- 30
- 47
-
1in the Class which extends activity and where you wanted to capture home button – Dinesh Prajapati Nov 29 '12 at 10:38
-
-
so where is your application is running? is it a widget? or service? – Dinesh Prajapati Nov 29 '12 at 10:41
-
then it's not possible because it's in the background UI less thing which is not affected with home key press. – Dinesh Prajapati Nov 29 '12 at 10:46
-
-
0
To handle key event
you have to override the methods onKeyDown()
and onKeyUp().
see this link will guide you just you have to add your logic.

Chintan Khetiya
- 15,962
- 9
- 47
- 85