【问题标题】:How to change the frequency of interstitial ads如何更改插页式广告的频率
【发布时间】:2015-04-27 14:57:43
【问题描述】:

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

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

为每个新的intent 加载插页式广告有点过火。如何操纵插页式广告在每 5 个意图后加载?

【问题讨论】:

  • 您在第二次加载插页式广告时是否收到任何消息?
  • @VVB 不。加载插页式广告对我来说效果很好。

标签: android admob ads interstitial


【解决方案1】:

创建一个整数

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

【讨论】:

  • isloaded && showbigad>4条件下添加showbigad=0后,完美运行。将 int 重置为 0 的 oncreate 部分不起作用,因为活动不会继续重新创建,或者如果确实如此,那么 showbigad 将​​永远不会超过 1。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-10-21
  • 1970-01-01
相关资源
最近更新 更多