AdMob request fail

半世苍凉 提交于 2019-12-23 04:50:27

问题


I'm running an app with AdMob ads. It works nicely, but sometimes the server can't serve an ad, so I thought about serving my own ads (plain images served from my own server). Is there any way to set a callback to the AdRequest so if the request fails, the callback is called?


回答1:


You're looking for AdMob's AdListener:

public interface AdListener {
  public void onReceiveAd(Ad ad);
  public void onFailedToReceiveAd(Ad ad, AdRequest.ErrorCode error);
  public void onPresentScreen(Ad ad);
  public void onDismissScreen(Ad ad);
  public void onLeaveApplication(Ad ad);
}

Specifically, the onFailedToReceiveAd callback tells you when AdMob couldn't return an ad. Have your class implement this interface to get all these callbacks. Just don't forget to set the AdListener on your AdView:

adView.setAdListener(this);


来源:https://stackoverflow.com/questions/13027706/admob-request-fail

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!