MediationInterstitialAdapter

public interface MediationInterstitialAdapter extends MediationAdapter


Adapter for third party ad networks that support interstitial ads.

The typical life-cycle for an adapter is to have [requestInterstitialAd] called once. At this point the adapter should request an ad from the ad network and report to the listener either [MediationInterstitialListener.onAdLoaded] or [MediationInterstitialListener.onAdFailedToLoad]. Subsequent requests will be made with a new instance of the adapter. At the end of the life cycle, a best effort is made to call onDestroy(), though this is not guaranteed. Note that [requestInterstitialAd] is called on the UI thread so all the standard precautions of writing code on that thread apply. In particular, the code should not call any blocking methods.

The adapter is expected to forward events via the [MediationInterstitialListener] passed in the [requestInterstitialAd] call. All parameters necessary to make an ad request should be passed in the [serverParameters], [mediationAdRequest], and [mediationExtras] parameters.

Summary

Public methods

abstract void
requestInterstitialAd(
    @NonNull Context context,
    @NonNull MediationInterstitialListener listener,
    @NonNull Bundle serverParameters,
    @NonNull MediationAdRequest mediationAdRequest,
    Bundle mediationExtras
)

Called by the mediation library to request an ad from the adapter.

abstract void

Shows the interstitial.

Inherited methods

From com.google.android.gms.ads.mediation.MediationAdapter
abstract void

Tears down the adapter control.

abstract void

Called when the application calls onPause on the ad view.

abstract void

Called when the application calls onResume on the ad view.

Public methods

requestInterstitialAd

abstract void requestInterstitialAd(
    @NonNull Context context,
    @NonNull MediationInterstitialListener listener,
    @NonNull Bundle serverParameters,
    @NonNull MediationAdRequest mediationAdRequest,
    Bundle mediationExtras
)

Called by the mediation library to request an ad from the adapter.

If the request is successful, the MediationInterstitialListener.onAdLoaded method should be called. The interstitial should NOT be automatically shown at this point. The showInterstitial method is called when the interstitial should be shown.

If the request is unsuccessful, the MediationInterstitialListener.onAdFailedToLoad method should be called on the listener with an appropriate error cause.

Note that this method is called on the UI thread, so all the general precautions of writing code on that thread apply. In particular, the code should not call any blocking methods.

Parameters
@NonNull Context context

The Context of the AdView which will contain the banner View.

@NonNull MediationInterstitialListener listener

Listener to adapter with callbacks for various events.

@NonNull Bundle serverParameters

Additional parameters defined by the publisher on the mediation server side.

@NonNull MediationAdRequest mediationAdRequest

Generic parameters for this publisher to use when making his ad request.

Bundle mediationExtras

Additional parameters set by the publisher on a per-request basis.

showInterstitial

abstract void showInterstitial()

Shows the interstitial. This may be called any time after MediationInterstitialListener.onAdLoaded is invoked.