public class AppOpenAd

  1. Object
  2. AppOpenAd

A full screen ad shown while the application is being brought to the foreground, overlaying the launch/splash experience.

App open ads are loaded ahead of time and shown when the user returns to the app. The recommended way to use them is to let Codename One and the provider manage the foreground hook for you:

AppOpenAd ad = new AppOpenAd("ca-app-pub-xxx/yyy");
AdManager.enableAppOpenAds(ad); // loads and auto-shows on foreground

Foreground detection is performed natively by the provider (Android process lifecycle / iOS applicationDidBecomeActive), which also honours the ad’s freshness window (an app open ad expires a few hours after loading).

Constructors

public AppOpenAd(String adUnitId)Creates an app open ad for the given ad unit id.

Methods

public void setAutoShowOnForeground(boolean enabled)Enables or disables the provider managed auto-show when the app returns to the foreground.
public void setAdListener(AdListener listener)Sets the listener notified of this ad’s lifecycle events.
public AdListener getAdListener()The listener notified of this ad’s lifecycle events, may be null.
public void load()Loads an ad with default targeting.
public void load(AdRequest request)Loads an ad using the supplied targeting metadata.
public boolean isLoaded()True when an ad is loaded and ready to show().
public void show()Presents the loaded ad.
public void dispose()Releases the resources held by this ad.

Inherited methods

Constructor details

AppOpenAd

public AppOpenAd(String adUnitId)
Creates an app open ad for the given ad unit id.

Parameters

adUnitId String
the ad unit identifier from the network console

Method details

setAutoShowOnForeground

public void setAutoShowOnForeground(boolean enabled)
Enables or disables the provider managed auto-show when the app returns to the foreground. Normally driven by AdManager.enableAppOpenAds(AppOpenAd).

Parameters

enabled boolean
true to auto-show on foreground

setAdListener

public void setAdListener(AdListener listener)
Sets the listener notified of this ad’s lifecycle events.

getAdListener

public AdListener getAdListener()
The listener notified of this ad’s lifecycle events, may be null.

load

public void load()
Loads an ad with default targeting.

load

public void load(AdRequest request)
Loads an ad using the supplied targeting metadata.

Parameters

request AdRequest
optional targeting metadata, may be null

isLoaded

public boolean isLoaded()
True when an ad is loaded and ready to show().

show

public void show()
Presents the loaded ad. Does nothing if no ad is loaded.

dispose

public void dispose()
Releases the resources held by this ad.