I new in AdMob. At first I'm trying to create a test app with different types of ad.
I use real ad_unit_id and nexus 4 for testing.
I use 1 layout xml for all activity:
When i create simple activity with banner ad it's work fine. Activity code:
public class AdBannerActivity extends Activity {
private AdView adView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ad_empty);
adView = new AdView(this, AdSize.SMART_BANNER, getString(R.string.adUnitId));
adView.setAdListener(this);
LinearLayout layout = (LinearLayout) findViewById(R.id.empty_layout);
layout.addView(adView);
adView.loadAd(new AdRequest());
}
@Override
public void onDestroy() {
if (adView != null) {
adView.destroy();
}
super.onDestroy();
}
}
When i try to create activity with full screen ad, i have error message:
Ad request successful, but no ad returned due to lack of ad inventory.
Activity code:
public class AdInterstitialActivity extends Activity implements AdListener {
private InterstitialAd interstitial;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ad_empty);
interstitial = new InterstitialAd(this, getString(R.string.adUnitId));
interstitial.setAdListener(this);
AdRequest adRequest = new AdRequest();
interstitial.loadAd(adRequest);
}
@Override
public void onReceiveAd(Ad ad) {
if (ad == interstitial) {
interstitial.show();
}
}
@Override
public void onDismissScreen(Ad ad) {
}
@Override
public void onFailedToReceiveAd(Ad ad, ErrorCode error) {
Log.e("AdTest", "Error code: " + error);
}
@Override
public void onLeaveApplication(Ad ad) {
}
@Override
public void onPresentScreen(Ad ad) {
}
}
What am I doing wrong?
How to solve this problem?