如何设置在 android 中加载插页式广告的时间?

how to set time to load interstitial ads in android?

我是第一次使用 adsmob sdk。我不知道如何按我想要的方式加载广告。这是我的代码:

    mInterstitialAd = new InterstitialAd(this);

    // set the ad unit ID
    InterstitialAd.setAdUnitId(getString(R.string.interstitial_full_screen));

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

    // Load ads into Interstitial Ads
    mInterstitialAd.loadAd(adRequest);

    mInterstitialAd.setAdListener(new AdListener() {
        public void onAdLoaded() {
            showInterstitial();
        }
    });
}

private void showInterstitial() {
    if (mInterstitialAd.isLoaded()) {
        mInterstitialAd.show();
    }
}

如果您使用计时器弹出插页式广告,您的 admob 帐户将被禁止。

如果您想在活动结束后展示插页式广告,请尝试以下操作: 例如,如果您正在使用 webview,并希望在页面加载后显示插页式广告:

Public class ads extends AppCompatActivity {
 InterstitialAd mInterstitialAd;

 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

      //This is where you initialize ads
      mInterstitialAd = new InterstitialAd(this);
      mInterstitialAd.setAdUnitId("ca-app-pub-xxxxxxxxxx");
      //This function request new Interstitial.
      requestNewInterstitial();


     myWebView.setWebChromeClient(new WebChromeClient() {
     public void onProgressChanged(WebView view, int newProgress) {
      progress.setProgress(newProgress);
       progress.setVisibility(View.VISIBLE);

         if (newProgress == 100) {

         progress.setVisibility(View.GONE); 
       // Interstitialads is shown after calling mInterstitial.show()
           mInterstitialAd.show();              
           }
         }

         }
    );

 }
//This function initializes new ads.
 private void requestNewInterstitial() {
    AdRequest adRequest = new AdRequest.Builder().build();
    mInterstitialAd.loadAd(adRequest);
 }

 }