App restart on restore

Hi community,
Quick question: Have anyone had problems minimising/maximising the App in Android?
My App restarts when I maximise it again.

  1. I’m playing my game…
  2. I want to minimise the App (maybe because I want to send a whatsapp or whatever)
  3. When I maximise it again, the app is automatically restarted. It seems like I’m running the app again, but not, I only wanted to maximise it.

I’m using applicationWillEnterForeground as default (cocos 3.17.2). Also I tried pausing Director there, but it didn’t work.

Suggestions?
Thanks!

i didn’t have problems with that, are you sure you are not calling director->end()?
Did you clone from github or using 3.17.2 zip version?

Hi @lmartinignacio !
Yes, I’m using cocos2d 3.17.2, these are my methods:

void AppDelegate::applicationDidEnterBackground() {
    Director::getInstance()->stopAnimation();

#if USE_AUDIO_ENGINE
    AudioEngine::pauseAll();
#elif USE_SIMPLE_AUDIO_ENGINE
    SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
    SimpleAudioEngine::getInstance()->pauseAllEffects();
#endif
}

// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground() {
    Director::getInstance()->startAnimation();

#if USE_AUDIO_ENGINE
    AudioEngine::resumeAll();
#elif USE_SIMPLE_AUDIO_ENGINE
    SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
    SimpleAudioEngine::getInstance()->resumeAllEffects();
#endif
} 

It’s happening on my old Android 4.
Any ideas?

Yup, that’s ok. that is how the appDelegate is in any new project

only in Android 4.0 api level 14?
Check the gradle.properties in proj.android folder and make sure PROP_MIN_SDK_VERSION is targeting what you need. by default is 16.

Or try compiling with a different ndk.

other than that, nope, i’m lost sry.

hey @lmartinignacio
In my Android project, PROP_MIN_SDK_VERSION=21
It’s working and compiling on my Android 4.
And my NDK version is r16b.

Anyway I don’t think NDK or PROP_MIN_SDK_VERSION are related to this issue :thinking: