如何更改插页式广告的频率

How to change the frequency of interstitial ads

目前,我的主页有 10 个按钮,每个按钮都有插页式广告。

    if (mInterstitialAd.isLoaded()) {
        mInterstitialAd.show();
    } else {
        Intent intent = new Intent(this, magic.class);
        startActivity(intent);
    }

为每个新 intent 加载插页式广告有点过分了。我怎样才能操纵插页式广告在每 5 个意图后加载?

创建一个整数

private int showbigad =0;

在 OnCreate 中...

SharedPreferences prefs = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE); 
String restoredText = prefs.getString("text", null);
if (restoredText != null) {
int advalue = prefs.getInt("showad", 0); 
showbigad=advalue;
}

现在每次点击我们都会添加到 showbigad

EACHONEOFYOURBUTTONS.onClick....{
showbigad =showbigad+1;
SharedPreferences.Editor editor = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE).edit();
editor.putInt("showad", showbigad);
editor.commit();
}});

现在,如果按钮被点击超过 4 次,插页式广告就会显示

if (mInterstitialAd.isLoaded()&& showbig>4) {
    mInterstitialAd.show();
} else {
    Intent intent = new Intent(this, magic.class);
    startActivity(intent);
}