The following two functions are defined in CCAplication:

virtual void applicationDidEnterBackground() = 0;
virtual void applicationWillEnterForeground() = 0;

However, they not called by the framework anywhere. Are they supposed to be called by cocos2d-x or by application code?

Thanks & regards,


hello, Leon, as the comments of the two functions showing, these two functions are callback functions.
you could realize them in your own apllication if you have something to do when you enter the background or enter the foreground.

brief The function be called when the application enter backgroundparam the pointer of the application
virtual void applicationDidEnterBackground() = 0;


Thank you, RongHong. The problem is that these function are not called by cocos2d-x. My question is should the framework be modified so these function get called somewhere or should I call these function in my app code?


oh, I have found the functions through out the whole project of cocos2d-x, and they are not called by the framework.
it seems that they should be called through jni in your own app code,
this is my opinion, hope that it is helpful for you.

btw, about jni, you can refer to


Thank you for making it clear.