Reputation: 457
I have to show a popup window on click of home screen button. I have tried using the below code onkeydown()
, but on click of home key button it's not coming into the loop.
if(keyCode == KeyEvent.KEYCODE_HOME)
{
//do something
}
Also i tried using onUserLeaveHint()
, but no use.
If any one knows about this kindly let me know.
Upvotes: 0
Views: 878
Reputation: 2495
It is not possible to override the home button, it is required by the system. See this answer by the Android Developer, Romain Guy https://stackoverflow.com/a/5039586/1578771.
Also, in future its better to use onKeyUp() as you'll be able to use other events like long presses etc.
Upvotes: 1
Reputation: 22156
You can't. The API doesn't let you capture the press of that key. It's a safety key. Refer to this question for more details.
Upvotes: 1