1. 程式人生 > >cocos構建的android項目的返回鍵相應

cocos構建的android項目的返回鍵相應

dispatch .get spa and activity back tac oid androi

  @Override
    public boolean dispatchKeyEvent(KeyEvent event) {
        //返回鍵  cocosActivity不相應onbackPressed和onKeyDown
        if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN){
            LogUtils.i("dispatchKeyEvent");
            getMainState();
        }
        return super.dispatchKeyEvent(event);
    }

cocos構建的android項目的返回鍵相應