cocos构建的android项目的返回键相应

 

  @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);
    }

 

posted @ 2018-09-12 18:27  小师傅啊小师傅  阅读(320)  评论(0编辑  收藏  举报