Admobs 广告显示不正确

Admobs ad not showing properly

我为 android 创建了一个简单的棋盘游戏,游戏结束后我遇到了广告问题。我使用这个简单的函数

public void afterEnd(){
        showInterstitial(); //dixnei tin diafimisi
        goToNextLevel();    //paei sto ending PRIN tin diafimisi gia na min fenete periergo
    }

显示广告然后转到下一个activity。问题是广告永远不会出现在 time.Game 继续到下一个 activity 并且只有当玩家按下 phone 上的后退键转到上一个时广告才会出现屏幕.

我的另外 2 个函数是:

private void showInterstitial() {
        if (mInterstitialAd != null && mInterstitialAd.isLoaded()) {
            mInterstitialAd.show();
        }
    }

private void goToNextLevel() {
startActivity(new Intent(getApplicationContext(), ScoreScreen.class));
        finish();
}

如果您需要任何其他代码,请随时告诉我。

广告生命周期中有多个事件。您可以通过 AdListener class 监听这些事件。调用 goToNextLevel() 方法 onAdClosed() method.Check 此代码片段可让您更好地理解。

mInterstitialAd.setAdListener(new AdListener() {
    @Override
    public void onAdLoaded() {
        // Code to be executed when an ad finishes loading.

    }

    @Override
    public void onAdFailedToLoad(int errorCode) {
        // Code to be executed when an ad request fails.
    }

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

    @Override
    public void onAdClicked() {
        // Code to be executed when the user clicks on an ad.
    }

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

    @Override
    public void onAdClosed() {
        // Code to be executed when the interstitial ad is closed.
         goToNextLevel()
    }
});