Android handling screen lock states

Topics: Actions and Control Logic, Android
Jun 30, 2014 at 9:11 PM
When the device screen gets locked my game exits and does not return to the state it was at when the screen is unlocked.

can someone point out the proper way to handle this.

i already included the following code below and it is not helping thanks
public override void ApplicationDidEnterBackground()
        // stop all of the animation actions that are running.

        // if you use SimpleAudioEngine, your music must be paused
        //CCSimpleAudioEngine.SharedEngine.PauseBackgroundMusic = true;

    public override void ApplicationWillEnterForeground()

        // if you use SimpleAudioEngine, your background music track must resume here. 
        //CCSimpleAudioEngine.SharedEngine.PauseBackgroundMusic = false;
Jul 3, 2014 at 11:23 PM
You have to restore your own game state. While the framework can restore the textures that were loaded, it's up to the game developer to restore the state of the game.
Jul 7, 2014 at 10:56 PM
Adding ConfigChanges.ScreenSize to my activity fixed the problem got it from

hope this helps someone

Thanks for the help totallyevil
Jul 7, 2014 at 11:59 PM
ok. Sorry - I misunderstood your use of 'state' in the question.

This happens on android devices that have a portrait-only screen lock, like the Samsung Galaxy Nexus (generation 1) phone, and your game is a landscape only game.

this might be something useful to put into the android game template.