- Guidelines of implementing the ad
- Make sure that the layout of the ad is set to View.GONE. We will show it only if there is an ad serve.
- Add the AdListener
mAdView = (AdView) findViewById(R.id.adView); mAdView.setAdListener(new AdListener() { @Override public void onAdClosed() { super.onAdClosed(); } @Override public void onAdLoaded() { super.onAdLoaded(); mAdView.setVisibility(View.VISIBLE); } @Override public void onAdOpened() { super.onAdOpened(); } @Override public void onAdFailedToLoad(int errorCode) { super.onAdFailedToLoad(errorCode); mAdView.setVisibility(View.GONE); } });As you see, we only set the method onAdLoaded() to be visible and onAdFailedToLoad to be gone. Because,
onAdOpened() - This will only happen if the ad will overlay the app after the user taps the ad. onAdClosed() - This will trigger if the overlay of the ad will be closed by the user.
That's it. Thanks.