Search code examples
javaandroidperformanceandenginelogcat

Android Back Key Issue


I'm developing a game via Andengine for Android. I have big problem. When I open my game first time, it's opening well. And when I press back key button(which is on device, pyhsical button), the app is closing. But it mustn't be close. And here is the LogCat:

http://s27.postimg.org/3mhwb3j2b/Capture.png

And when I try to open app again, it is opening black blank scene.

PLS help!


Solution

  • try to override onKeyDown and block BACK button

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) 
    {
        if(keyCode==KeyEvent.KEYCODE_BACK)
            return true;
    
        return super.onKeyDown(keyCode, event);
    }
    

    That should prevent user from exit App with Back button