Skip to content

Instantly share code, notes, and snippets.

@ayltai
Created February 12, 2017 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayltai/37200436bd4748cce819e3a1bbd37012 to your computer and use it in GitHub Desktop.
Save ayltai/37200436bd4748cce819e3a1bbd37012 to your computer and use it in GitHub Desktop.
Fetch ad for AdMob
@Override
public void fetchAd() {
new AdLoader.Builder(this.getContext(), this.adUnitId)
.forAppInstallAd(AdMobNativeAd.this)
.forContentAd(AdMobNativeAd.this)
.withNativeAdOptions(this.getNativeAdOptionsBuilder().build())
.withAdListener(new AdListener() {
@Override
public void onAdOpened() {
AdMobNativeAd.this.notifyAdClicked();
}
@Override
public void onAdFailedToLoad(final int errorCode) {
AdMobNativeAd.this.onAdFailedToLoad(errorCode);
}
})
.build()
.loadAd(this.getAdRequestBuilder().build());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment