-1

In android i have been able to override the funcationality of back button very easily but for my app i need to override the home button. I am sure it can be done but how can i achieve this.

Harshit Rathi
  • 1,862
  • 2
  • 18
  • 25
  • NO! you can not override android home key click event it prevented by system, only onStop method will call on home key click event. – Vijju Mar 10 '14 at 11:17
  • but when press home button i want to show an alert so how can i do this. – Harshit Rathi Mar 10 '14 at 11:19
  • on click of home key only onStop of activity will call, therefor displaying an alert on stop is not possible. – Vijju Mar 10 '14 at 11:23

1 Answers1

0

Sorry to say but, It is not possible.Refer the link:-

http://developer.android.com/reference/android/view/KeyEvent.html#KEYCODE_HOME`

Key code constant: Home key. This key is handled by the framework and is never delivered to applications.

Many blogs suggest to use onPause() method of activity life cycle,for the same.But it takes a lot to manage.

I will suggest to use onUserLeaveHint() method.

Harshal Benake
  • 2,391
  • 1
  • 23
  • 40