package com.test.qiao;
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.WindowManager;
public class ZZZActivity extends Activity {
private boolean flag = true;//true为屏蔽,false、为不屏蔽
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
@Override
public void onAttachedToWindow() {
if(flag) {
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
}
super.onAttachedToWindow();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_HOME){
return true;
}
return super.onKeyDown(keyCode, event);
}
}
android 如何屏蔽Home键(长按短按都不起作用)
最新推荐文章于 2024-03-19 11:02:08 发布