当我关闭并插播非页内广告时,它会发生意外的活动

时间:2019-01-28 17:30:10

标签: java android

早上好,这似乎是问题所在。在我的onAdClosed中,放置了“ ThirdActivity.class”,但是当我关闭Admob插页式广告时,它转到了另一个活动。

    mInterstitialAd = new InterstitialAd(this);
    mInterstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
    mInterstitialAd.loadAd(new AdRequest.Builder().build());
    mInterstitialAd.setAdListener(new com.google.android.gms.ads.AdListener() {
        @Override
        public void onAdClosed() {
         Intent intent = new Intent(Dashboard.this, 3rdActivity.class);
         startActivity(intent);
        }
        @Override
        public void onAdLoaded() { Log.i("Ads", "onAdLoaded"); }
        @Override
        public void onAdFailedToLoad(int errorCode) { Log.i("Ads", "onAdFailedToLoad"); }
        @Override
        public void onAdOpened() { Log.i("Ads", "onAdOpened"); }
        @Override
        public void onAdLeftApplication() { Log.i("Ads", "onAdLeftApplication"); }
    });
     .
     .
     .
     builder.setNeutralButton("Continue", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (mInterstitialAd != null && mInterstitialAd.isLoaded()) {
                mInterstitialAd.show();
            } else {
                Intent intent = new Intent(Dashboard.this, ThirdActivity.class);
                startActivity(intent);
            }
        }
    });
    AlertDialog coldialog = builder.create();
    coldialog.show();

0 个答案:

没有答案