InterstitialAdPreloader.Companion

public static class InterstitialAdPreloader.Companion extends AdPreloader


Summary

Public methods

static boolean
destroy(@NonNull String preloadId)

Permanently stops preloading for the given preloadId and destroys all associated preloaded ads.

static PreloadConfiguration

Returns the PreloadConfiguration associated with this preloadId and ad format, or null if one does not exist.

static @NonNull Map<@NonNull String, @NonNull PreloadConfiguration>

Returns a map of all PreloadConfigurations associated with this format, keyed by preload ID.

static int

Returns the number of preloaded ads available for the given preloadId.

static boolean

Returns true if at least one ad is available for the given preloadId.

static int

This method is deprecated. Use {@link #getNumAdsAvailable} instead

static InterstitialAd
pollAd(@NonNull String preloadId)

Returns an ad preloaded from start or null if no ad is available.

static boolean
start(
    @NonNull String preloadId,
    @NonNull PreloadConfiguration preloadConfiguration
)

Starts preloading without a callback.

static boolean
start(
    @NonNull String preloadId,
    @NonNull PreloadConfiguration preloadConfiguration,
    PreloadCallback preloadCallback
)

Starts preloading ads for the given PreloadConfiguration + preloadId and returns true.

Public methods

destroy

public static boolean destroy(@NonNull String preloadId)

Permanently stops preloading for the given preloadId and destroys all associated preloaded ads.

Returns true if preloading was stopped, false if there is no active preload for preloadId.

getConfiguration

public static PreloadConfiguration getConfiguration(@NonNull String preloadId)

Returns the PreloadConfiguration associated with this preloadId and ad format, or null if one does not exist.

getConfigurations

public static @NonNull Map<@NonNull String, @NonNull PreloadConfigurationgetConfigurations()

Returns a map of all PreloadConfigurations associated with this format, keyed by preload ID.

getNumAdsAvailable

public static int getNumAdsAvailable(@NonNull String preloadId)

Returns the number of preloaded ads available for the given preloadId.

isAdAvailable

public static boolean isAdAvailable(@NonNull String preloadId)

Returns true if at least one ad is available for the given preloadId.

numAdsAvailable

public static int numAdsAvailable(@NonNull String preloadId)

Returns the number of preloaded ads available for the given preloadId.

pollAd

public static InterstitialAd pollAd(@NonNull String preloadId)

Returns an ad preloaded from start or null if no ad is available.

Note that this may be any of the ads preloaded for preloadId. The order returned is not guaranteed to match the order of PreloadCallback.onAdPreloaded events.

start

public static boolean start(
    @NonNull String preloadId,
    @NonNull PreloadConfiguration preloadConfiguration
)

Starts preloading without a callback.

start

public static boolean start(
    @NonNull String preloadId,
    @NonNull PreloadConfiguration preloadConfiguration,
    PreloadCallback preloadCallback
)

Starts preloading ads for the given PreloadConfiguration + preloadId and returns true.

The SDK will continue to preload ads until the number the number of ads specified by PreloadConfiguration.bufferSize is reached, attempting to keep the buffer full throughout the session.

Each ad request the SDK attempts results in either a PreloadCallback.onAdPreloaded or PreloadCallback.onAdFailedToPreload callback. The SDK includes retry logic for requests that fail.

If a PreloadConfiguration was already started with preloadId, this method becomes a no-op and returns false.

Parameters
@NonNull String preloadId

A string identifier for this PreloadConfiguration + ad format. Use this identifier for all future calls to control preloading for this PreloadConfiguration, like pollAd or destroy.

@NonNull PreloadConfiguration preloadConfiguration

The configuration to preload ads for.

PreloadCallback preloadCallback

A callback to be invoked when ad availability changes for the given PreloadConfiguration.

Returns
boolean

True if preloading started, false otherwise.