TAGS :Viewed: 7 - Published at: a few seconds ago

[ How to avoid unnecessary reloads of Google Ads on my Android App ]

I made an Andriod App, it's a typing game, that have several levels. The thing is that I'm showing ads in the bottom of the screen every time that the player fail (because if you type wrong, you fail)

So the thing is that every time that the player fail the activity reloads to start again. So with that, the ad is reloading and doing another request.

I try to search if it's any way to avoid this but I was not able.

So what I want to do, is to make and Adrequest just the first time that the game is loaded, and then just put it visible or invisible.

By the way if you want to take a look at the app is in the google play: Doctor Key

Thank you!

Answer 1

I would redesign your Activity so that it doesn't have to recreate itself every time you start again. Maybe add reset() and setLevel() methods that reinitializes everything and set the state for whatever level you're doing.

Alternatively you could look into using Fragments. Then you simply replace the level fragment, while leaving the ad section in a separate Fragment that would not be affected.