Prevent Ad from triggering multiple times

Started by
0 comments, last by Nanoha 8 years, 2 months ago

Hello, I need your help plz.

When I run this code on a real device the ad-banner pops up endless times. How should I modifiy this code to run it just once? This code is from a game. Every time the player gets hit by something he loses 1 shield.

private void showBanner() {

adView.setVisibility(View.VISIBLE);
adView.loadAd(new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build());
}

if (player.getShieldStrength() == 0){
runOnUiThread(new Runnable() {
@Override
public void run() {
showBanner();
}
});
}

This my logcat:

Aborting last ad request since another ad request is already in progress.
The current request object will still be cached for future refreshes.
...

Advertisement

Can you not use a flag such as (I am not too familiar with Java)


if(player.getShieldStrength() == 0 && asView.getVisibility() != View.VISIBLE)

Interested in Fractals? Check out my App, Fractal Scout, free on the Google Play store.

This topic is closed to new replies.

Advertisement