当我调用 setType(TYPE_KEYGUARD) 时,无法捕获 Home 键事件
我想捕获 Home 键,但我在 onAttachedToWindow
中调用了 setType(WindowManager.LayoutParam.TYPE_KEYGUARD)
,但它不起作用,我无法接收 Home 键onKeyDown
谁遇到过这个问题?请给一些建议或者有其他解决方案。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据我的测试,这个解决方案不再有效,至少从 Android 4.0 开始是这样。只有操作系统应该处理 HOME 按钮。如果您希望在用户按下 HOME 时显示,请实现主屏幕。
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.