Android InterstitalAd gray small bar bevor the ad

36 views Asked by At

Im trying to get a InterstitialAd into my application. It works now,

However:

1) I always get a small gray bar displayed on top of the screen during the ad is loading 2) The ad takes really long to load

any ideas how to fix these two problems?

BannerActivity:

public class BannerActivity extends Activity{

private InterstitialAd mInterstitialAd;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mInterstitialAd = new InterstitialAd(this);
    mInterstitialAd.setAdUnitId("ca-app-pub-XXXXXX");
    requestNewInterstitial();

    mInterstitialAd.setAdListener(new AdListener() {
        @Override
        public void onAdLoaded(){
            mInterstitialAd.show();
        }

        @Override
        public void onAdClosed() {
            finish();
        }
    });

}

private void requestNewInterstitial() {
    AdRequest adRequest = new AdRequest.Builder().addTestDevice("XXXXXXXXXXXX").build();
    mInterstitialAd.loadAd(adRequest);
}
}

How i load the banner:

 Intent bannerIntent = new Intent(myContext, BannerActivity.class);
 myContext.startActivity(bannerIntent);

xml:

 android:name="kletzgames.crazyballs.BannerActivity"
 android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
 android:theme="@android:style/Theme.Translucent" />
1

There are 1 answers

0
Marc Kletz On

I fixed it:

I now call the Ad during another View so it can load, and ones it loaded it will be displayed during screenTransaction.

AdRequest adRequest = new AdRequest.Builder().addTestDevice("XXXX").build();
mInterstitialAd.loadAd(adRequest);

** some if's **
mInterstitialAd.show();