BannerAd

interface BannerAd : Ad


An SDK-rendered rectangular ad that occupies a portion of an app's layout.

Summary

Public companion functions

suspend AdLoadResult<BannerAd>
load(adRequest: BannerAdRequest)

This function is deprecated. Use AdView.loadAd() or BannerAdPreloader instead.

Unit
load(
    adRequest: BannerAdRequest,
    adLoadCallback: AdLoadCallback<BannerAd>
)

This function is deprecated. Use AdView.loadAd() or BannerAdPreloader instead.

Unit
loadFromAdResponse(
    adResponse: String,
    adLoadCallback: AdLoadCallback<BannerAd>
)

This function is deprecated. Use AdView.loadAd() or BannerAdPreloader instead.

Public functions

AdSize

Returns the AdSize of this BannerAd.

View
getView(activity: Activity)

This function is deprecated. Use AdView.registerBannerAd() instead.

Boolean

Returns true if the ad is a collapsible banner.

Unit

Records a manual impression.

Public properties

BannerAdEventCallback?

Optional callback for ad events during the lifecycle of this BannerAd.

BannerAdRefreshCallback?

Optional callback for refresh events from this BannerAd.

VideoController?

Video controller used to control the video asset served using Ad Manager native styles.

Inherited functions

From com.google.android.libraries.ads.mobile.sdk.common.Ad
Unit

Destroys the ad, stopping any extra processing and destroying resources associated with the ad.

ResponseInfo

Gets information about the ad response for this ad.

Inherited properties

From com.google.android.libraries.ads.mobile.sdk.common.Ad
Long

An identifier for a placement in reporting.

Public companion functions

load

suspend fun load(adRequest: BannerAdRequest): AdLoadResult<BannerAd>

Loads a BannerAd, suspending until a BannerAd successfully loads or fails to load.

Parameters
adRequest: BannerAdRequest

A BannerAdRequest with targeting information.

Returns
AdLoadResult<BannerAd>

AdLoadResult.Success if the load succeeded, AdLoadResult.Failure otherwise.

load

fun load(
    adRequest: BannerAdRequest,
    adLoadCallback: AdLoadCallback<BannerAd>
): Unit

Loads a banner ad, providing the result via adLoadCallback.

Parameters
adRequest: BannerAdRequest

An ad request with targeting information.

adLoadCallback: AdLoadCallback<BannerAd>

A callback to be invoked when loading completes.

loadFromAdResponse

fun loadFromAdResponse(
    adResponse: String,
    adLoadCallback: AdLoadCallback<BannerAd>
): Unit

Loads a banner ad, providing the result via adLoadCallback.

Parameters
adResponse: String

An ad response from a server-to-server ad request.

adLoadCallback: AdLoadCallback<BannerAd>

A callback to be invoked when loading completes.

Public functions

getAdSize

fun getAdSize(): AdSize

Returns the AdSize of this BannerAd.

getView

fun getView(activity: Activity): View

Returns the banner View rendered by the Google Mobile Ads SDK.

isCollapsible

fun isCollapsible(): Boolean

Returns true if the ad is a collapsible banner.

recordManualImpression

fun recordManualImpression(): Unit

Records a manual impression. For this method to have any effect, the loaded ad must allow the impression to be recorded manually.

This feature is available to Ad Manager publishers only.

Public properties

adEventCallback

var adEventCallbackBannerAdEventCallback?

Optional callback for ad events during the lifecycle of this BannerAd.

bannerAdRefreshCallback

var bannerAdRefreshCallbackBannerAdRefreshCallback?

Optional callback for refresh events from this BannerAd.

videoController

val videoControllerVideoController?

Video controller used to control the video asset served using Ad Manager native styles. Returns null for banner ads not using this feature.