Android 捕捉HOME键

jopen 7年前

    // 屏蔽Home键           @Override           public void onAttachedToWindow() {                this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);                super.onAttachedToWindow();           }  
    // 捕获home键           @Override           public boolean onKeyDown(int keyCode, KeyEvent event) {                switch (keyCode) {                case KeyEvent.KEYCODE_HOME:                     finish();                }                return super.onKeyDown(keyCode, event);           }