RewardedAd

public interface RewardedAd extends Ad


A full screen ad that provides the user the opportunity to opt-in to watching a video or engaging with a playable ad in exchange for a reward within the app.

Summary

Nested types

public static class RewardedAd.Companion

Public methods

abstract RewardedAdEventCallback

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

abstract @NonNull Bundle

Gets all available ad metadata for this RewardedAd.

abstract @NonNull RewardItem

Gets the RewardItem for the loaded rewarded ad.

default static final void
load(
    @NonNull AdRequest adRequest,
    @NonNull AdLoadCallback<@NonNull RewardedAd> adLoadCallback
)

Loads a RewardedAd, providing the result via adLoadCallback.

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

Loads a RewardedAd, providing the result via adLoadCallback.

abstract void

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

abstract void
setImmersiveMode(boolean immersiveModeEnabled)

Sets a flag that controls if this rewarded object will be displayed in immersive mode.

abstract void

Sets ServerSideVerificationOptions for this RewardedAd.

abstract void
show(
    @NonNull Activity activity,
    @NonNull OnUserEarnedRewardListener onUserEarnedRewardListener
)

Shows the rewarded ad.

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 RewardedAdEventCallback getAdEventCallback()

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

getAdMetadata

abstract @NonNull Bundle getAdMetadata()

Gets all available ad metadata for this RewardedAd. Ad metadata is empty if the loaded ad doesn't have metadata. Ad metadata may update after loading. Use RewardedAdEventCallback.onAdMetadataChanged to listen for changes:

ad.adEventCallback = object : RewardedAdEventCallback {
override fun onAdMetadataChanged() {
val metadata = ad.getAdMetadata()
}
}

getRewardItem

abstract @NonNull RewardItem getRewardItem()

Gets the RewardItem for the loaded rewarded ad.

load

default static final void load(
    @NonNull AdRequest adRequest,
    @NonNull AdLoadCallback<@NonNull RewardedAd> adLoadCallback
)

Loads a RewardedAd, providing the result via adLoadCallback.

Parameters
@NonNull AdRequest adRequest

An ad request with targeting information.

@NonNull AdLoadCallback<@NonNull RewardedAd> adLoadCallback

A callback to be invoked when a rewarded ad finishes loading.

loadFromAdResponse

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

Loads a RewardedAd, providing the result via adLoadCallback.

Parameters
@NonNull String adResponse

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

@NonNull AdLoadCallback<@NonNull RewardedAd> adLoadCallback

A callback to be invoked when loading completes.

setAdEventCallback

abstract void setAdEventCallback(RewardedAdEventCallback adEventCallback)

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

setImmersiveMode

abstract void setImmersiveMode(boolean immersiveModeEnabled)

Sets a flag that controls if this rewarded object will be displayed in immersive mode. Call this method before RewardedAd.show. During RewardedAd.show, if this flag is on and immersive mode is supported, the rewarded ad will turn on the SYSTEM_UI_FLAG_IMMERSIVE_STICKY & SYSTEM_UI_FLAG_HIDE_NAVIGATION flags.

setServerSideVerificationOptions

abstract void setServerSideVerificationOptions(
    @NonNull ServerSideVerificationOptions options
)

Sets ServerSideVerificationOptions for this RewardedAd.

show

abstract void show(
    @NonNull Activity activity,
    @NonNull OnUserEarnedRewardListener onUserEarnedRewardListener
)

Shows the rewarded ad.

Parameters
@NonNull Activity activity

An Activity context from which to present the ad.

@NonNull OnUserEarnedRewardListener onUserEarnedRewardListener

The listener to be notified when user earns a reward.