public interface AdProvider

The service provider interface implemented by an ad network library (such as the Google AdMob library). A provider is the seam that lets the com.codename1.ads API stay network agnostic: AdMob, AppLovin MAX, Unity LevelPlay or a custom mediation layer can each be plugged in by implementing this interface and registering with AdManager.registerProvider(AdProvider).

A library typically exposes a static install() method that constructs and registers its provider, so applications enable it with a single line. Applications never reference this type directly; they use AdManager and the format classes.

Methods

public abstract String getName()A short human readable provider name, e.g. “AdMob”.
public abstract boolean isSupported()True when this provider can run on the current platform.
public abstract boolean isFormatSupported(AdFormat format)True when this provider supports the given ad format.
public abstract void initialize(AdConfig config, AdCallback<Boolean> onComplete)Initializes the underlying SDK.
public abstract FullScreenAdSession createFullScreenAd(AdFormat format, String adUnitId)Creates a session for a full screen ad of the given format.
public abstract BannerAdSession createBanner(String adUnitId, int bannerSize, int widthDp)Creates a banner session of the requested size.
public abstract AdConsentController getConsentController()The consent controller for this provider.

Method details

getName

public abstract String getName()
A short human readable provider name, e.g. “AdMob”.

isSupported

public abstract boolean isSupported()
True when this provider can run on the current platform.

isFormatSupported

public abstract boolean isFormatSupported(AdFormat format)
True when this provider supports the given ad format.

initialize

public abstract void initialize(AdConfig config, AdCallback<Boolean> onComplete)
Initializes the underlying SDK. Must invoke the callback (with Boolean.TRUE on success) when initialization completes. Implementations should be idempotent.

Parameters

config AdConfig
the global ad configuration
onComplete AdCallback<Boolean>
invoked when initialization finishes

createFullScreenAd

public abstract FullScreenAdSession createFullScreenAd(AdFormat format, String adUnitId)
Creates a session for a full screen ad of the given format. Returns null if the format is unsupported.

Parameters

format AdFormat
one of the full screen formats
adUnitId String
the ad unit identifier from the network console

createBanner

public abstract BannerAdSession createBanner(String adUnitId, int bannerSize, int widthDp)
Creates a banner session of the requested size. Returns null if banners are unsupported.

Parameters

adUnitId String
the ad unit identifier from the network console
bannerSize int
one of the size constants in BannerAd
widthDp int
requested width in display-independent pixels for adaptive banners, or 0 to use the available width

getConsentController

public abstract AdConsentController getConsentController()
The consent controller for this provider. Returns null if the provider has no consent management of its own.