AdLoader.Builder

class AdLoader.Builder


Builder for a AdLoader.

Summary

Public constructors

Builder(context: Context!, adUnitID: String!)

Creates a new Builder for constructing an AdLoader.

Public functions

AdLoader!

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

AdLoader.Builder!

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

AdLoader.Builder!

Enables the AdLoader to load custom format ads.

AdLoader.Builder!

Registers a listener to handle loading a NativeAd.

AdLoader.Builder!
AdLoader.Builder!

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

AdLoader.Builder!

Sets the native ad options to the ad loader builder.

Public constructors

Builder

Builder(context: Context!, adUnitID: String!)

Creates a new Builder for constructing an AdLoader.

Parameters
context: Context!

The context.

adUnitID: String!

The ad unit ID.

Public functions

build

fun build(): AdLoader!

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

forAdManagerAdView

@CanIgnoreReturnValue
fun forAdManagerAdView(
    listener: OnAdManagerAdViewLoadedListener,
    adSizes: Array<AdSize!>!
): AdLoader.Builder!

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

Parameters
listener: OnAdManagerAdViewLoadedListener

The callback that will run when a banner ad loads.

adSizes: Array<AdSize!>!

Sets the supported sizes of the banner ad.

Throws
java.lang.IllegalArgumentException

If adSizes is null or empty.

forCustomFormatAd

@CanIgnoreReturnValue
fun forCustomFormatAd(
    customFormatId: String!,
    adLoadedListener: NativeCustomFormatAd.OnCustomFormatAdLoadedListener!,
    customClickListener: NativeCustomFormatAd.OnCustomClickListener?
): AdLoader.Builder!

Enables the AdLoader to load custom format ads.

Parameters
customFormatId: String!

Custom format ID defined in the Ad Manager UI.

adLoadedListener: NativeCustomFormatAd.OnCustomFormatAdLoadedListener!

A listener to be called when a NativeCustomFormatAd loads.

customClickListener: NativeCustomFormatAd.OnCustomClickListener?

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.

forNativeAd

@CanIgnoreReturnValue
fun forNativeAd(listener: NativeAd.OnNativeAdLoadedListener!): AdLoader.Builder!

Registers a listener to handle loading a NativeAd.

Parameters
listener: NativeAd.OnNativeAdLoadedListener!

A listener to be called when a NativeAd loads.

withAdListener

@CanIgnoreReturnValue
fun withAdListener(listener: AdListener!): AdLoader.Builder!
Parameters
listener: AdListener!

An object that handles errors encountered when retrieving native ads.

withAdManagerAdViewOptions

@CanIgnoreReturnValue
fun withAdManagerAdViewOptions(options: AdManagerAdViewOptions!): AdLoader.Builder!

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

Parameters
options: AdManagerAdViewOptions!

Google Ad Manager banner ad options.

withNativeAdOptions

@CanIgnoreReturnValue
fun withNativeAdOptions(options: NativeAdOptions!): AdLoader.Builder!

Sets the native ad options to the ad loader builder.

Parameters
options: NativeAdOptions!

An object that specifies various native ad options.