Cocos Creator how to check android Build is foreground and background

Hello sir,
i need to mange foreground and background process in my game.i found something that mention its not working 100%.

i was working before in cocos2dx and recently move to cocos creator so i am converting my game to creator but i am not found how to mange game in foreground and background.

in cocos2dx there is code something like below that every time call when its go to background.

// This function will be called when the app is inactive. Note, when receiving a phone call it is invoked.
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
}

How to mange in cocos creator.

Thanks

The event is not 100% guaranteed to be fired on Web platform, on android, it corresponds to enter background event, you can add event like: game.on(Game.EVENT_SHOW, this.onEventShow)

ok Thanks

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.