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

时间:2015-04-27 03:37:56

标签: android admob ads interstitial

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

$scope.$watch('activedMenu', function(newVal, oldVal){
   //on watch code here
}, true);

为每个新 if (mInterstitialAd.isLoaded()) { mInterstitialAd.show(); } else { Intent intent = new Intent(this, magic.class); startActivity(intent); } 加载插页式广告虽然有点过分。如何在每5次意图后操纵插页式广告加载?

1 个答案:

答案 0 :(得分:2)

创建一个整数

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);
}