1.屏蔽Home键
@Override
public void onAttachedToWindow() {
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}
2.屏蔽返回键、MENU键
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
return true;// true 屏蔽 false 不屏蔽
} else if (keyCode == KeyEvent.KEYCODE_MENU) {
return true;// true 屏蔽 false 不屏蔽
}
return super.onKeyDown(keyCode, event);
}
如果觉得《关于屏蔽MENU键 返回键 Home键等代码。》对你有帮助,请点赞、收藏,并留下你的观点哦!