com.google.ads.mediation
Interface MediationBannerAdapter<ADDITIONAL_PARAMETERS extends NetworkExtras,SERVER_PARAMETERS extends MediationServerParameters>

Type Parameters:
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.)
All Superinterfaces:
MediationAdapter<ADDITIONAL_PARAMETERS,SERVER_PARAMETERS>
All Known Implementing Classes:
AdMobAdapter, CustomEventAdapter

public interface MediationBannerAdapter<ADDITIONAL_PARAMETERS extends NetworkExtras,SERVER_PARAMETERS extends MediationServerParameters>
extends MediationAdapter<ADDITIONAL_PARAMETERS,SERVER_PARAMETERS>

Adapter for third party ad networks that support banner ads.

The typical life-cycle for an adapter is to have requestBannerAd(com.google.ads.mediation.MediationBannerListener, android.app.Activity, SERVER_PARAMETERS, com.google.ads.AdSize, 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 MediationBannerListener.onReceivedAd(com.google.ads.mediation.MediationBannerAdapter) or MediationBannerListener.onFailedToReceiveAd(com.google.ads.mediation.MediationBannerAdapter, 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 requestBannerAd(com.google.ads.mediation.MediationBannerListener, android.app.Activity, SERVER_PARAMETERS, com.google.ads.AdSize, 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 expose events via the MediationBannerListener passed in the requestBannerAd(com.google.ads.mediation.MediationBannerListener, android.app.Activity, SERVER_PARAMETERS, com.google.ads.AdSize, 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.


Method Summary
 View getBannerView()
          Returns a View that can be rendered to display the ad.
 void requestBannerAd(MediationBannerListener listener, Activity activity, SERVER_PARAMETERS serverParameters, AdSize adSize, MediationAdRequest mediationAdRequest, ADDITIONAL_PARAMETERS mediationExtras)
          Called by the mediation library to request an ad from the adapter.
 
Methods inherited from interface com.google.ads.mediation.MediationAdapter
destroy, getAdditionalParametersType, getServerParametersType
 

Method Detail

requestBannerAd

void requestBannerAd(MediationBannerListener listener,
                     Activity activity,
                     SERVER_PARAMETERS serverParameters,
                     AdSize adSize,
                     MediationAdRequest mediationAdRequest,
                     ADDITIONAL_PARAMETERS mediationExtras)
Called by the mediation library to request an ad from the adapter.

If the request is successful, the MediationBannerListener.onReceivedAd(com.google.ads.mediation.MediationBannerAdapter) method should be called.

If the request is unsuccessful, the MediationBannerListener.onFailedToReceiveAd(com.google.ads.mediation.MediationBannerAdapter, com.google.ads.AdRequest.ErrorCode) method should be called on the listener with an appropriate error cause.

This method is called on the UI thread so all the standard precautions of writing code on that thread apply. In particular your code should not call any blocking methods.

Parameters:
listener - Listener to adapter with callbacks for various events
activity - Android Activity which is displaying the ad
serverParameters - Additional parameters defined by the publisher on the mediation server side
adSize - The size of the ad to fetch. The ad size returned should have size as close as possible to the size specified in this parameter. If this ad size is not supported the request should fail and MediationAdapterListener.onFailedToReceiveAd should be called.
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

getBannerView

View getBannerView()
Returns a View that can be rendered to display the ad.

This must not be null after a requestBannerAd(com.google.ads.mediation.MediationBannerListener, android.app.Activity, SERVER_PARAMETERS, com.google.ads.AdSize, com.google.ads.mediation.MediationAdRequest, ADDITIONAL_PARAMETERS) call and before a MediationAdapter.destroy() call. It may be null any other time.