Search code examples
androidandroid-homebutton

can't capture Home key event when i have call setType(TYPE_KEYGUARD)


I want capture the Home key, but I have call setType(WindowManager.LayoutParam.TYPE_KEYGUARD) in onAttachedToWindow, but it doesn't work, I can't receive Home key in onKeyDown

Who have happen this problem? Please give some suggestion or have other solution.


Solution

  • This solution no longer works, at least as of Android 4.0, based on my testing. Only the OS should handle the HOME button. If you want to be displayed when the user presses HOME, implement a home screen.