cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.2k stars 7.06k forks source link

Activity issues after launch app first time, from play store, ... and reopening from icon on Android #16687

Open GabrieleGervasi opened 8 years ago

GabrieleGervasi commented 8 years ago

Steps to Reproduce:

  1. Integrate something able to start new activity from your app (we are currently using sdkbox iap, play, appodeal that starts new activity),
  2. Run/Compile,Install,Start your app
  3. When app start start new activity (ex in my case. play video for appodeal, show achievements, ...)
  4. Return to device home without close app
  5. Re-open app using icon
  6. Note that activity has been stopped

The problem seems to be related to android issues reported in this answer: http://stackoverflow.com/a/16447508

I managed to solve with answer workaround, but unfortunately i'm totally inexperienced in android activities. Note that with these steps the issue will only be present first time you install and launch the app, if you restart this doesn't happen. There are others methods for this to happen as for example launch the app from play store, return on device home without close, clicking app icon.

rmont881 commented 7 years ago

This also causes some other issues as well, that are still present even with the fix you linked. When it creates the second activity, it creates a new instance of mEditBoxHelper in Cocos2dxActivity. The problem with this is when it creates a new instance of that object, it clears out the static list mEditBoxArray in Cocos2dxEditBoxHelper. If you have an EditBox on screen and do the same steps you've described above, it no longer has those EditBox's in mEditBoxArray and cannot open the keyboard or accept input.