Android屏蔽后退键的小例子

时间:2021-12-07 07:14:10

复制代码 代码如下:


public boolean onKeyDown(int keyCode, KeyEvent event) {
         if (event.getAction() == KeyEvent.ACTION_DOWN
                 && event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
             return true;//消费掉后退键
         }
         return super.onKeyDown(keyCode, event);
     }