android屏蔽HOME键的方法
在相应的Activity中加入:
public void onAttachedToWindow()
{ this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD); super.onAttachedToWindow();
}
下面是FRAMWORK层的代码,里面的type == WindowManager.LayoutParams.TYPE_KEYGUARD条件是返回FALSE
if (code == KeyEvent.KEYCODE_HOME) {// If a system window has focus, then it doesn't make sense// right now to interact with applications.WindowManager.LayoutParams attrs = win != null ? win.getAttrs() : null;if (attrs != null) {final int type = attrs.type;if (type == WindowManager.LayoutParams.TYPE_KEYGUARD|| type == WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG) {// the "app" is keyguard, so give it the keyreturn false;}final int typeCount = WINDOW_TYPES_WHERE_HOME_DOESNT_WORK.length;for (int i=0; i
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
