0

I have 3 activity A, B, and C and I am showing interstitial ad in activity B. But problem is if I instantly back in activity A, interstitial appear in activity A. If I instantly go next activity C, interstitial appear in activity C. But I want interstitial will show only in activity B. Google haven't accept my app update for this reason.

spectre_d2
  • 193
  • 15

2 Answers2

1

try this way

InterstitialAd mInterstitial = new InterstitialAd(this);
                mInterstitial.setAdUnitId(getResources().getString(Your_init_id));
                AdRequest adRequest = new AdRequest.Builder().build();
                mInterstitial.setAdListener(new AdListener() {
                    @Override
                    public void onAdLoaded() {
                        Log.d("==","onAdLoaded");
                        mInterstitial.show();
                    }

                    @Override
                    public void onAdFailedToLoad(int errorCode) {
                        // Code to be executed when an ad request fails.
                        Log.d("==","onAdFailedToLoad"+errorCode);
                        moveToOtherActivity();
                    }


                    @Override
                    public void onAdOpened() {
                        // Code to be executed when the ad is displayed.
                    }

                    @Override
                    public void onAdLeftApplication() {
                        // Code to be executed when the user has left the app.
                    }

                    @Override
                    public void onAdClosed() {
                        // Code to be executed when when the interstitial ad is closed.
                        Log.d("==","onAdClosed");
                        moveToOtherActivity();
                    }
                });
                mInterstitial.loadAd(adRequest);

            }

         private void moveToOtherActivity() {
            Intent intent;
            intent = new Intent(this,Activity_which_you_want_to_display_after_interstitial .class);
            startActivity(intent);
            finish();
        }
pratik vekariya
  • 1,105
  • 1
  • 8
  • 14
0

There is a way to hide an interstitial discussed in this post

This doesn't prevent it from appearing, it just closes it.

Hope it helps

Joan
  • 321
  • 1
  • 10