# Interface AdProvider

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.

- ## Method Summary

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

- ## Method Details

  - ### getName

    String getName()
    A short human readable provider name, e.g. "AdMob".

  - ### isSupported

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

  - ### isFormatSupported

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

  - ### initialize

    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`: the global ad configuration
    - `onComplete`: invoked when initialization finishes

  - ### createFullScreenAd

    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`: one of the full screen formats
    - `adUnitId`: the ad unit identifier from the network console

  - ### createBanner

    BannerAdSession createBanner(String adUnitId, int bannerSize, int widthDp)

    Creates a banner session of the requested size. Returns null if banners are unsupported.

    ###### Parameters

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

  - ### getConsentController

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