BannerAd

public interface BannerAd extends Ad


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

Summary

Nested types

public static class BannerAd.Companion

Public methods

abstract BannerAdEventCallback

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

abstract @NonNull AdSize

Returns the AdSize of this BannerAd.

abstract BannerAdRefreshCallback

Optional callback for refresh events from this BannerAd.

abstract VideoController

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

abstract @NonNull View

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

abstract boolean

Returns true if the ad is a collapsible banner.

default static final void
load(
    @NonNull BannerAdRequest adRequest,
    @NonNull AdLoadCallback<@NonNull BannerAd> adLoadCallback
)

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

default static final void
loadFromAdResponse(
    @NonNull String adResponse,
    @NonNull AdLoadCallback<@NonNull BannerAd> adLoadCallback
)

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

abstract void

Records a manual impression.

abstract void

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

abstract void
setBannerAdRefreshCallback(
    BannerAdRefreshCallback bannerAdRefreshCallback
)

Optional callback for refresh events from this BannerAd.

Inherited methods

From com.google.android.libraries.ads.mobile.sdk.common.Ad
abstract void

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

abstract long

An identifier for a placement in reporting.

abstract @NonNull ResponseInfo

Gets information about the ad response for this ad.

abstract void
setPlacementId(long placementId)

An identifier for a placement in reporting.

Public methods

getAdEventCallback

abstract BannerAdEventCallback getAdEventCallback()

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

getAdSize

abstract @NonNull AdSize getAdSize()

Returns the AdSize of this BannerAd.

getBannerAdRefreshCallback

abstract BannerAdRefreshCallback getBannerAdRefreshCallback()

Optional callback for refresh events from this BannerAd.

getVideoController

abstract VideoController getVideoController()

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

getView

abstract @NonNull View getView(@NonNull Activity activity)

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

isCollapsible

abstract boolean isCollapsible()

Returns true if the ad is a collapsible banner.

load

default static final void load(
    @NonNull BannerAdRequest adRequest,
    @NonNull AdLoadCallback<@NonNull BannerAd> adLoadCallback
)

Loads a banner ad, providing the result via adLoadCallback.

Parameters
@NonNull BannerAdRequest adRequest

An ad request with targeting information.

@NonNull AdLoadCallback<@NonNull BannerAd> adLoadCallback

A callback to be invoked when loading completes.

loadFromAdResponse

default static final void loadFromAdResponse(
    @NonNull String adResponse,
    @NonNull AdLoadCallback<@NonNull BannerAd> adLoadCallback
)

Loads a banner ad, providing the result via adLoadCallback.

Parameters
@NonNull String adResponse

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

@NonNull AdLoadCallback<@NonNull BannerAd> adLoadCallback

A callback to be invoked when loading completes.

recordManualImpression

abstract void recordManualImpression()

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.

setAdEventCallback

abstract void setAdEventCallback(BannerAdEventCallback adEventCallback)

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

setBannerAdRefreshCallback

abstract void setBannerAdRefreshCallback(
    BannerAdRefreshCallback bannerAdRefreshCallback
)

Optional callback for refresh events from this BannerAd.