AdLoader.Builder

public static class AdLoader.Builder extends Object

Builder for a AdLoader.

Public Constructor Summary

Builder(Context context, String adUnitID)
Creates a new AdLoader.Builder for constructing an AdLoader.

Public Method Summary

AdLoader
build()
Returns an AdLoader or empty if there was an error was encountered.
AdLoader.Builder
forAdManagerAdView(OnAdManagerAdViewLoadedListener listener, AdSize... adSizes)
Registers a listener to handle loading a Google Ad Manager banner ad.
AdLoader.Builder
forCustomFormatAd(String customFormatId, NativeCustomFormatAd.OnCustomFormatAdLoadedListener adLoadedListener, NativeCustomFormatAd.OnCustomClickListener customClickListener)
Enables the AdLoader to load custom format ads.
AdLoader.Builder
forNativeAd(NativeAd.OnNativeAdLoadedListener listener)
Registers a listener to handle loading a NativeAd.
AdLoader.Builder
AdLoader.Builder
withAdManagerAdViewOptions(AdManagerAdViewOptions options)
Sets options to use for loading a Google Ad Manager ad view.
AdLoader.Builder
withNativeAdOptions(NativeAdOptions options)
Sets the native ad options to the ad loader builder.

Inherited Method Summary

Public Constructors

public Builder (Context context, String adUnitID)

Creates a new AdLoader.Builder for constructing an AdLoader.

Parameters
context The context.
adUnitID The ad unit ID.

Public Methods

public AdLoader build ()

Returns an AdLoader or empty if there was an error was encountered.

public AdLoader.Builder forAdManagerAdView (OnAdManagerAdViewLoadedListener listener, AdSize... adSizes)

Registers a listener to handle loading a Google Ad Manager banner ad.

Parameters
listener The callback that will run when a banner ad loads.
adSizes Sets the supported sizes of the banner ad.
Throws
IllegalArgumentException If adSizes is null or empty.

public AdLoader.Builder forCustomFormatAd (String customFormatId, NativeCustomFormatAd.OnCustomFormatAdLoadedListener adLoadedListener, NativeCustomFormatAd.OnCustomClickListener customClickListener)

Enables the AdLoader to load custom format ads.

Parameters
customFormatId Custom format ID defined in the Ad Manager UI.
adLoadedListener A listener to be called when a NativeCustomFormatAd loads.
customClickListener An optional listener to define custom click logic for ad clicks. When set, this overrides the ad's default click through behavior of navigating to the click URL defined in the Ad Manager UI.

public AdLoader.Builder forNativeAd (NativeAd.OnNativeAdLoadedListener listener)

Registers a listener to handle loading a NativeAd.

Parameters
listener A listener to be called when a NativeAd loads.

public AdLoader.Builder withAdListener (AdListener listener)

Parameters
listener An object that handles errors encountered when retrieving native ads.

public AdLoader.Builder withAdManagerAdViewOptions (AdManagerAdViewOptions options)

Sets options to use for loading a Google Ad Manager ad view.

Parameters
options Google Ad Manager banner ad options.

public AdLoader.Builder withNativeAdOptions (NativeAdOptions options)

Sets the native ad options to the ad loader builder.

Parameters
options An object that specifies various native ad options.