屏掉按键比较容易,如下:
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
// 返回true,不响应其他key
return true;
}
屏掉HOME的方法两种,一种是通用方法:
public void onAttachedToWindow() {
// 关键:在onAttachedToWindow中设置TYPE_KEYGUARD,即可屏蔽
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}
另一种是一个网友研究出来的,
public void onAttachedToWindow() {
WindowManager.LayoutParams lp=getWindow().getAttributes();
lp.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT; //2010,2003
getWindow().setType(lp.type);
super.onAttachedToWindow();
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
// 返回true,不响应其他key
return true;
}
屏掉HOME的方法两种,一种是通用方法:
public void onAttachedToWindow() {
// 关键:在onAttachedToWindow中设置TYPE_KEYGUARD,即可屏蔽
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
super.onAttachedToWindow();
}
另一种是一个网友研究出来的,
public void onAttachedToWindow() {
WindowManager.LayoutParams lp=getWindow().getAttributes();
lp.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT; //2010,2003
getWindow().setType(lp.type);
super.onAttachedToWindow();
}