6

I implemented this android code to load and show an interstitial ad and after closing the ad it will open the target activity, but my problem is there's a 3 seconds delay between closing and opening the target activity...here's my code:

AdRequest adRequest = new AdRequest.Builder().build();

InterstitialAd.load(HomeActivity.this, UNIT_ID, adRequest, new InterstitialAdLoadCallback() {
    @Override
    public void onAdLoaded(@NonNull InterstitialAd interstitialAd) {
        // The mInterstitialAd reference will be null until
        // an ad is loaded.
        admobInterstitialAd = interstitialAd;
        admobInterstitialAd.setFullScreenContentCallback(new FullScreenContentCallback() {
            @Override
            public void onAdDismissedFullScreenContent() {
                super.onAdDismissedFullScreenContent();
                admobInterstitialAd = null;
            
                /**********Here is the delay when starting the activity for about 3 seconds*******/
                Intent intent = new Intent(HomeActivity.this, SettingsActivity.class);
                startActivity(intent);
                /********************************************************************************/
            }

            @Override
            public void onAdFailedToShowFullScreenContent(com.google.android.gms.ads.AdError adError) {
                super.onAdFailedToShowFullScreenContent(adError);
                admobInterstitialAd = null;
                
                Intent intent = new Intent(HomeActivity.this, SettingsActivity.class);
                startActivity(intent);
            }

            @Override
            public void onAdShowedFullScreenContent() {
                super.onAdShowedFullScreenContent();
                admobInterstitialAd = null;
            }
        });

        if (admobInterstitialAd != null) {
            admobInterstitialAd.show(HomeActivity.this);
        }
    }

    @Override
    public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
        // Handle the error
        admobInterstitialAd = null;

        Intent intent = new Intent(HomeActivity.this, SettingsActivity.class);
        startActivity(intent);
    }
});

Any suggestions to fix this issue....thanks in advance...

Haxer87
  • 61
  • 2

1 Answers1

2

I faced the same problem. I still haven't been able to fix the problem and couldn't find a resource that does. While searching on Google, I realized that you are not alone and those who have the same problem on other platforms.

As a workaround, I will use a progress dialog. This makes users wait until the ad closes and the new event starts. I think 1-3 seconds.

if (mInterstitialAd != null) {
            mInterstitialAd.show(MainAct.this);
            startActivity(new Intent(MainAct.this, NewAct.class));
            progressDialog.show();
        } else {
            startActivity(new Intent(MainAct.this, MafA.class));
        }
serif
  • 199
  • 2
  • 12