I am testing Ads in an Android app. I want a button to be shown when the ad is loaded, and then click on the button to show the ad.
My issue is that the ad is never loaded.
This is my code so far:
MobileAds.initialize(getActivity(), "ca-app-pub-***"); mInterstitialAd = new InterstitialAd(getActivity()); mInterstitialAd.setAdUnitId("ca-app-pub-ca-app-pub-***"); mInterstitialAd.loadAd(new AdRequest.Builder().build()); btnOfertar.setVisibility(View.GONE); mInterstitialAd.setAdListener(new AdListener() { @Override public void onAdLoaded() { // Code to be executed when an ad finishes loading. Log.i("Ads", "onAdLoaded"); btnOfertar.setVisibility(View.VISIBLE); } });
mInterstitialAd.show();on methodonAdLoaded(), and edit yourmInterstitialAd.setAdUnitId("ca-app-pub-ca-app-pub-***");tomInterstitialAd.setAdUnitId("ca-app-pub-***");. Also, checkLogCatfor more info.