applicationDidEnterBackground/ applicationDidEnterForeground sequence executed twice

Hi,

on Android when my app goes to background, I see in the log the following sequence :

04-19 08:59:20.055: D/cocos2d-x debug info(12482): >> FMAppDelegate::applicationDidEnterBackground - jni/…/…/Classes/FMAppDelegate.cpp:287

(do some stuff when in background)

04-19 08:59:20.055: D/cocos2d-x debug info(12482): << FMAppDelegate::applicationDidEnterBackground - jni/…/…/Classes/FMAppDelegate.cpp:294

(execute a notification to do some treatment when in background

04-19 08:59:25.360: D/OpenGLRenderer(12482): Flushing caches (mode 0)
04-19 08:59:25.360: D/MainActivity(12482): >> onDestroy
04-19 08:59:25.360: D/MainActivity(12482): << onDestroy
04-19 08:59:25.400: W/SurfaceView(12482): CHECK surface infomation creating=false formatChanged=false sizeChanged=false visible=false visibleChanged=true surfaceChanged=true realSizeChanged=false redrawNeeded=false left=false top=false
04-19 08:59:25.425: D/MainActivity(12482): >> onCreate
04-19 08:59:25.525: D/MainActivity(12482): << onCreate
04-19 08:59:25.530: D/cocos2d-x debug info(12482): >> FMAppDelegate::applicationWillEnterForeground - jni/…/…/Classes/FMAppDelegate.cpp:308
04-19 08:59:25.530: D/cocos2d-x debug info(12482): << FMAppDelegate::applicationWillEnterForeground - jni/…/…/Classes/FMAppDelegate.cpp:313

(call a notification to do some stuff when back to foreground)

04-19 08:59:25.560: D/cocos2d-x debug info(12482): >> FMAppDelegate::applicationDidEnterBackground - jni/…/…/Classes/FMAppDelegate.cpp:287

(do some stuff when in background)

04-19 08:59:25.560: D/cocos2d-x debug info(12482): << FMAppDelegate::applicationDidEnterBackground - jni/…/…/Classes/FMAppDelegate.cpp:294

(execute a notification to do some treatment when in background

What I don’t understant is why applicationDidEnterBackground is called twice and why applicationWillEnterForeground is called right after applicationDidEnterBackground ?

I suppose it comes from the call in SurfaceView which causes theactivity to be redraw, but I don’t know how this SurfaceView is called

Does anyone had this problem too?

Thanks for your help

Nico

Hi Nico,
We’re experiencing the exact same issue, but not on all android devices. It happens on S3 and N4 but not in the Xoom tablet for instance.
Did you figured it out?
Thanks

Found the problem, when the lockscreen appears an orientation/sizeScreen change is triggered, and the activy is destroyed/created. Fix: http://stackoverflow.com/a/16771885/128533