1.只屏蔽Home键,只需在Activity中重写onAttachedToWindow()方法
public static final int FLAG_HOMEKEY_DISPATCHED = 0x80000000;
@Overridepublic void onAttachedToWindow() {
//关键:在onAttachedToWindow中设置FLAG_HOMEKEY_DISPATCHED
this.getWindow().addFlags(FLAG_HOMEKEY_DISPATCHED);
super.onAttachedToWindow();}
2.只屏蔽返回键,只需在Activity中重写onBackPressed()方法
public void onBackPressed() {
// super.onBackPressed();
// 屏蔽掉返回按键
}
网友评论