Close and Reopening Cocos2d-x Activity in native application

Hi,
my app is a tiny game store
the store developed by native java and the game player developed by Cocos2d-x.
the games are similar with different textures, databases and different scenarios.

in my store, by selecting each game i’ll start Cocos2d-x Activity and everything works fine but when i close the game player by Director::getInstance()->end(); my native store activity will be restarted.
seems end() command want to destroy whole app process.

How can i quit my game player without any error and open it again for another game?

Many Thanks.
Sorry for my bad english.

Why don’t you call a “finish” of the Activity via JNI? This would trigger the Activity lifecycle and should also end the cocos instance.

1 Like

i tried that and didn’t throw any exception and crashes.
but when i start cocos activity again it will resume the last game.
finishing cocos activity not ended the cocos instance.
after opening activity again it will call AppDelegate::applicationWillEnterForeground()
should i call specific method after calling finish() method?

I didn’t tried it by myself yet, so I can’t say it for sure. I need to look more into the code to help with that, but I would be great to know, because I also plan to do a game like this.

1 Like

Many thanks

now i’m finishing activity by JNI and using AppDelegate::applicationWillEnterForeground() by clearing all the caches and rebuilding game scene again but it will cause load delay on reopening game (3-15 seconds).

i have also tried putting cocos activity in another process (by android:process attribute in android manifest) but when i start activity nothing happens.

i’ll keep you posted after finding solution.

1 Like