How to stop a DoubleClick interstitial

236 views Asked by At

I need to display a DoubleClick interstitial on Activity A and a simple DoubleClick banner on Activity B, and I need to display the interstitial during only 3 seconds and then go to Activity B (in case the use doesn't click on the interstitial close button).

Both interstitial and banner are currently displaying fine expect when I'm waiting these 3 seconds : in that case, the simple banner on Activity B doesn't show anymore on Activity B and I get this log :

loadAd called while an interstitial or landing page is displayed, so aborting

It seems that the only way to properly "undisplay" an interstitial is passing through the onDismissScreen function, but I can't do that neither.

My code is this one

@Override
public void onPresentScreen(Ad ad)
{
    if (ad == interstitial_ad)
    {
        // 3-second timer
        Handler handler = new Handler();
        handler.postDelayed(new Runnable()
        {
            public void run()
            {
                 startActivity(new Intent("Activity B"));
            }
        }, 3000);
    }
}

I already tried all these possibilities

if (interstitial_ad != null)
{
    interstitial_ad.stopLoading();
    interstitial_ad.loadAd(null);
    interstitial_ad.setAdListener(null);
    interstitial_ad = null;
}

and nothing works.

Any clue?

Thanks in advance.

1

There are 1 answers

0
Melquiades On

First, in your run() method, start your activity this way:

Intent intent = new Intent(this, ActivityB.class);  //<----whatever file Activity B resides in
startActivity(intent);
finish(); //<---add this to close the current activity

Next, add finish() in just after startActivity(). You might still try to stop your interstitial as your have shown.