• Advertisement
Sign in to follow this  

Prevent Ad from triggering multiple times

This topic is 816 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.
...

Share this post


Link to post
Share on other sites
Advertisement

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

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement