当前位置: 代码迷 >> Android >> Android 怎么屏蔽Home键
  详细解决方案

Android 怎么屏蔽Home键

热度:23   发布时间:2016-04-28 04:39:52.0
Android 如何屏蔽Home键
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);      }  }  
  相关解决方案