【发布时间】:2015-11-03 09:28:03
【问题描述】:
到现在为止的过去 15 天,我的 admob 插页式广告单元 id 的匹配请求总是太少。 有 15000 个插页式请求,我只得到了 ~1500 个匹配(~10%)。
我找不到根本原因。低匹配是来自admob服务器端还是客户端(这意味着我以错误的方式实现)。
有人可以帮助我,这是我实现的一些代码:
首先,我创建插页式广告。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initUI();
// setup interstitial admob
interstitial = new InterstitialAd(this);
interstitial.setAdUnitId(interstitial_ad_unit_id);
interstitial.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
super.onAdLoaded();
Log.d("AdListener", "onAdLoaded");
}
@Override
public void onAdFailedToLoad(int errorCode) {
super.onAdFailedToLoad(errorCode);
Log.d("AdListener", "onAdFailedToLoad");
if (isNetworkAvailable()) {
interstitial.loadAd(new AdRequest.Builder().build());
}
}
@Override
public void onAdOpened() {
super.onAdOpened();
Log.d("AdListener", "onAdOpened");
}
@Override
public void onAdClosed() {
super.onAdClosed();
Log.d("AdListener", "onAdClosed");
interstitial.loadAd(new AdRequest.Builder().build());
}
@Override
public void onAdLeftApplication() {
super.onAdLeftApplication();
Log.d("AdListener", "onAdLeftApplication");
}
});
interstitial.loadAd(new AdRequest.Builder().build());
}
然后,每当我需要展示广告时,我都会调用这个方法:
public static void displayInterstitial() {
if (interstitial.isLoaded()) {
interstitial.show();
} else {
// show another ads network instead of admob, such as StartApp
displayInterstitialStartApp();
// if interstitial is not loading then load again
if (!interstitial.isLoading()) {
interstitial.loadAd(new AdRequest.Builder().build());
}
}
}
【问题讨论】:
-
你们怎么看这个方法:onAdFailedToLoad()。在我看来,当它加载失败时,我会再次加载它,但 Admob 目前没有广告响应。然后它再次加载失败->然后加载......所以,我认为这是个大问题。它进入无限循环,请求太多但没有匹配。
标签: android admob google-play-services