Adapter for third party ad networks that support interstitial ads.
The typical life-cycle for an adapter is to have
requestInterstitialAd(Context, MediationInterstitialListener, Bundle, MediationAdRequest,
Bundle)
called once. At this point the adapter should request an ad from the ad
network and report to the listener either
onAdLoaded(MediationInterstitialAdapter)
or
onAdFailedToLoad(MediationInterstitialAdapter, AdError)
. 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(Context, MediationInterstitialListener, Bundle, MediationAdRequest,
Bundle)
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(Context, MediationInterstitialListener, Bundle, MediationAdRequest,
Bundle)
call. All parameters necessary to make an ad request should be passed in
the serverParameters
, MediationAdRequest
,
and mediationExtras
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.
Public Method Summary
abstract void |
requestInterstitialAd(Context
context,
MediationInterstitialListener listener, Bundle
serverParameters,
MediationAdRequest mediationAdRequest, Bundle
mediationExtras)
Called by the mediation library to request an ad from the adapter.
|
abstract void |
showInterstitial()
Shows the interstitial.
|
Inherited Method Summary
Public Methods
public abstract void requestInterstitialAd (Context context, MediationInterstitialListener listener, Bundle serverParameters, MediationAdRequest mediationAdRequest, Bundle mediationExtras)
Called by the mediation library to request an ad from the adapter.
If the request is successful, the
onAdLoaded(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
onAdFailedToLoad(MediationInterstitialAdapter, AdError)
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
context | The Context
of the AdView which will contain the banner View. The Activity
is preferred. |
---|---|
listener | Listener to adapter with callbacks for various events |
serverParameters | Additional parameters defined by the publisher on the mediation server side |
mediationAdRequest | Generic parameters for this publisher to use when making his ad request |
mediationExtras | Additional parameters set by the publisher on a per-request basis |
public abstract void showInterstitial ()
Shows the interstitial. This may be called any time after a call to
onAdLoaded(MediationInterstitialAdapter)
.