ADDITIONAL_PARAMETERS
- This is a class that can be used by publishers to pass any
additional parameters that the ad network requires.SERVER_PARAMETERS
- This is a class that holds any additional options that the publisher
can define in the mediation UI, passed to the ad network (IDs, global configurations,
etc.)public interface MediationInterstitialAdapter<ADDITIONAL_PARAMETERS extends NetworkExtras,SERVER_PARAMETERS extends MediationServerParameters> extends MediationAdapter<ADDITIONAL_PARAMETERS,SERVER_PARAMETERS>
The typical life-cycle for an adapter is to have requestInterstitialAd(com.google.ads.mediation.MediationInterstitialListener, android.app.Activity, SERVER_PARAMETERS, com.google.ads.mediation.MediationAdRequest, ADDITIONAL_PARAMETERS)
called once.
At this point the adapter should request an ad from the ad network and report to the listener
either MediationInterstitialListener.onReceivedAd(com.google.ads.mediation.MediationInterstitialAdapter<?, ?>)
or
MediationInterstitialListener.onFailedToReceiveAd(com.google.ads.mediation.MediationInterstitialAdapter<?, ?>, com.google.ads.AdRequest.ErrorCode)
. 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
MediationAdapter.destroy()
, though this is not guaranteed. Note that requestInterstitialAd(com.google.ads.mediation.MediationInterstitialListener, android.app.Activity, SERVER_PARAMETERS, com.google.ads.mediation.MediationAdRequest, ADDITIONAL_PARAMETERS)
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(com.google.ads.mediation.MediationInterstitialListener, android.app.Activity, SERVER_PARAMETERS, com.google.ads.mediation.MediationAdRequest, ADDITIONAL_PARAMETERS)
call. All parameters necessary to make an ad request
should be passed in the SERVER_PARAMETERS
, MediationAdRequest
, and
ADDITIONAL_PARAMETERS
parameters.
Adapters should make an effort to disable automatic ad refreshing on the client side. Ads that are refreshed may be ignored, not displayed, and counted incorrectly.
Modifier and Type | Method and Description |
---|---|
void |
requestInterstitialAd(MediationInterstitialListener listener,
Activity activity,
SERVER_PARAMETERS serverParameters,
MediationAdRequest mediationAdRequest,
ADDITIONAL_PARAMETERS mediationExtras)
Called by the mediation library to request an ad from the adapter.
|
void |
showInterstitial()
Shows the interstitial.
|
destroy, getAdditionalParametersType, getServerParametersType
void requestInterstitialAd(MediationInterstitialListener listener, Activity activity, SERVER_PARAMETERS serverParameters, MediationAdRequest mediationAdRequest, ADDITIONAL_PARAMETERS mediationExtras)
If the request is successful, the
MediationInterstitialListener.onReceivedAd(com.google.ads.mediation.MediationInterstitialAdapter<?, ?>)
method should be called. The
interstitial should *NOT* be automatically shown at this point. The mediation library will
call the showInterstitial()
method when the interstitial should be shown.
If the request is unsuccessful, the
MediationInterstitialListener.onFailedToReceiveAd(com.google.ads.mediation.MediationInterstitialAdapter<?, ?>, com.google.ads.AdRequest.ErrorCode)
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.
listener
- Listener to adapter with callbacks for various eventsactivity
- Android Activity which is displaying the adserverParameters
- Additional parameters defined by the publisher on the mediation
server sidemediationAdRequest
- Generic parameters for this publisher to use when making his ad
requestmediationExtras
- Additional parameters set by the publisher on a per-request basisvoid showInterstitial()
MediationInterstitialListener.onReceivedAd(com.google.ads.mediation.MediationInterstitialAdapter<?, ?>)
.