我有部分广告,但没有调用加载方法,它在logcat中提供以下警告:
11-04 09:32:02.046: I/Ads(29747): No fill from ad server.
11-04 09:32:02.066: W/Ads(29747): Failed to load ad: 3
我的横幅广告正在加载,但却没有使用Intersitial广告。
以下代码是为此写的:
AdRequest adRequest1 = new AdRequest.Builder().build();
InterstitialAd interstitial = new InterstitialAd(this);
interstitial.setAdUnitId(AD_UNIT_ID);
interstitial.loadAd(adRequest1);
interstitial.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
// TODO Auto-generated method stub
// super.onAdLoaded();
interstitial.show();
}
});
帮助
答案 0 :(得分:0)
是解决方案是您需要为横幅广告和最终用户广告提供不同的广告单元ID。对于测试设备,可以使用一个,但对于生产,您需要使用不同的广告单元ID。
Link寻求解决方案。
答案 1 :(得分:-1)
这是我的插页式广告示例,只需要根据需要折射代码:
public class InterstitialsAdsExampleActivity extends Activity implements
AdListener {
/** Called when the activity is first created. */
private InterstitialAd interstitialAds = null;
private TextView textView = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
this.interstitialAds = new InterstitialAd(this,"your ad-id here");
this.interstitialAds.setAdListener(this);
Button loadButton = (Button) this.findViewById(R.id.loadButton);
loadButton.setOnClickListener(loadButtonOnClick);
this.textView = (TextView) this.findViewById(R.id.stateTextView);
}
private OnClickListener loadButtonOnClick = new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
textView.setText("Loading Intertitial Ads");
AdRequest adr = new AdRequest();
// add your test device here
//adr.addTestDevice("your test device id here");
interstitialAds.loadAd(adr);
}
};
@Override
public void onDismissScreen(Ad arg0) {
// TODO Auto-generated method stub
}
@Override
public void onFailedToReceiveAd(Ad ad, ErrorCode error) {
String message = "Load Ads Failed: (" + error + ")";
textView.setText(message);
}
@Override
public void onLeaveApplication(Ad arg0) {
// TODO Auto-generated method stub
}
/**
* Called when an Activity is created in front of the app (e.g. an
* interstitial is shown, or an ad is clicked and launches a new Activity).
*/
@Override
public void onPresentScreen(Ad arg0) {
// TODO Auto-generated method stub
}
@Override
public void onReceiveAd(Ad arg0) {
if (interstitialAds.isReady()) {
interstitialAds.show();
} else {
textView.setText("Interstitial ad was not ready to be shown.");
}
}
}