SonarSystems / Cocos-Helper

Cocos2d-x external framework helper.
MIT License
120 stars 48 forks source link

Banner Ads not being displayed after app resume #49

Open uxdxdev opened 8 years ago

uxdxdev commented 8 years ago

Im having a weird issue with the AdMob ads. When the game starts, the ads are shown, thats fine. If I move to a new scene with Director::getInstance()->replaceScene(); The new scene loads, the ads are there, all is fine.

But on Google Analytics it shows that the active screen is

com.google.android.gms.ads.AdActivity

even though I have set the screen name using

SonarCocosHelper::GoogleAnalytics::setScreenName("Game Scene");

The problem occurs when I press the home button on my Galaxy S4. The app moves to the background, then when it is opened again the banner ads are gone. If I then use the Quit button which calls Director::getInstance()->end(); the screen goes black but the game just reloads, and the ads are displayed again. Its like there is a layer being created over the game showing the ads that is closed when I first hit Quit.

Im putting it down to the com.google.android.gms.ads.AdActivity created for displaying the ads.

How do I get the banner ads to be displayed after the app is resumed from being in the background? Or close the com.google.android.gms.ads.AdActivity view when the game is put in the background and then create it again on resume?

OscarLeif commented 8 years ago

That could be a problem with Cocos helper or Maybe Cocos2d-x itself (your game). But before check that please can you test that problem in another device ? I don't remember if that problem with the ads happened before, I remember that ads should appear after you return from the pause activity state. Check android activity lifecycle After all Android ads are like a native activity. About your game crash maybe you override some methods ? (very common issue).