Class 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).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()Releases the resources held by this ad.The listener notified of this ad's lifecycle events, may be null.booleanisLoaded()True when an ad is loaded and ready toshow().voidload()Loads an ad with default targeting.voidLoads an ad using the supplied targeting metadata.voidsetAdListener(AdListener listener) Sets the listener notified of this ad's lifecycle events.voidsetAutoShowOnForeground(boolean enabled) Enables or disables the provider managed auto-show when the app returns to the foreground.voidshow()Presents the loaded ad.
-
Constructor Details
-
AppOpenAd
Creates an app open ad for the given ad unit id.
Parameters
adUnitId: 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: true to auto-show on foreground
-
setAdListener
Sets the listener notified of this ad's lifecycle events. -
getAdListener
The listener notified of this ad's lifecycle events, may be null. -
load
public void load()Loads an ad with default targeting. -
load
Loads an ad using the supplied targeting metadata.
Parameters
request: optional targeting metadata, may be null
-
isLoaded
public boolean isLoaded()True when an ad is loaded and ready toshow(). -
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.
-