Okay this is embarrassing but I have been trying to load interstitial ad and it just does not load and I don't understand why even the logcat does not say anything. I have used the same code in two activities and obviously I am using the tester here. So when I click on the RelativeLayout it displays ad. The problem is it is displaying in one activity perfectly with the tester and does not in the other.
Here is what I tried.
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("ad-id");
mInterstitialAd.loadAd(new AdRequest.Builder().build());
layoutSaved.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mInterstitialAd.isLoaded()) {
mInterstitialAd.show();
} else {
Log.d(TAG, "The interstitial wasn't loaded yet.");
}
}
});
Tried using AdListener to Toast a message to check if it's loaded, and the ad gets loaded but does not open.
P.S: It's worthy to note that I get this error in logcat but everything runs perfectly E/RecyclerView: No adapter attached; skipping layout
and I tried these solutions solution 1 and solution 2 but honestly I don't think it will cause any problem (or will it?)