I'm trying to load interstitial ad on the tablet, with the test ad id. On output ad is not showing, but I'm getting the callback on "onAdLoaded".
This is my code:-
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ad_activity);
mPublisherInterstitialAd = new PublisherInterstitialAd(this);
mPublisherInterstitialAd.setAdUnitId("/6499/example/interstitial");
mPublisherInterstitialAd.loadAd(newPublisherAdRequest.Builder().build());
mPublisherInterstitialAd.setAdListener(new AdListener(){
@Override
public void onAdLoaded() {
Log.d("AD ","LOADED");
}
@Override
public void onAdFailedToLoad(int i) {
Log.d("AD ","FAILED");
}
});
}
Try this
public void inrequestadd() {
mInterstitial = new InterstitialAd(MainActivity.this);
mInterstitial.setAdUnitId("Your ID");
mInterstitial.loadAd(new AdRequest.Builder().build());
mInterstitial.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
super.onAdClosed();
}
@Override
public void onAdFailedToLoad(int errorCode) {
super.onAdFailedToLoad(errorCode);
}
@Override
public void onAdLoaded() {
super.onAdLoaded();
if (mInterstitial.isLoaded()) {
mInterstitial.show();
}
}
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With