App Open Ads
Integrate CloudX App Open ads in Android apps
App Open ads are fullscreen placements intended for app foreground moments, such as when a user returns to your app after it has been backgrounded.
Supported Networks
App Open demand is served by the following bidding networks:
The Google Mobile Ads waterfall adapter also supports App Open placements for AdMob waterfall demand.
class MainActivity : AppCompatActivity(), CloudXAppOpenListener, CloudXAdRevenueListener {
private lateinit var appOpenAd: CloudXAppOpenAd
private fun createAppOpenAd() {
appOpenAd = CloudX.createAppOpen(this, "your-app-open-ad-unit-id")
appOpenAd.listener = this
appOpenAd.revenueListener = this
appOpenAd.load()
}
private fun showAppOpenAd() {
if (appOpenAd.isAdReady) {
appOpenAd.show(this, "app_foreground")
}
}
// CloudXAppOpenListener callbacks
override fun onAdLoaded(cloudXAd: CloudXAd) {
Log.d("CloudX", "App Open ad loaded from ${cloudXAd.networkName}")
}
override fun onAdLoadFailed(adUnitId: String, cloudXError: CloudXError) {
Log.e("CloudX", "App Open ad failed to load: ${cloudXError.message}")
}
override fun onAdDisplayed(cloudXAd: CloudXAd) {
Log.d("CloudX", "App Open ad displayed")
}
override fun onAdDisplayFailed(cloudXAd: CloudXAd, cloudXError: CloudXError) {
Log.e("CloudX", "App Open ad failed to display: ${cloudXError.message}")
appOpenAd.load()
}
override fun onAdHidden(cloudXAd: CloudXAd) {
appOpenAd.load()
}
override fun onAdClicked(cloudXAd: CloudXAd) {}
// CloudXAdRevenueListener callback
override fun onAdRevenuePaid(cloudXAd: CloudXAd) {
Log.d("CloudX", "App Open bid-time revenue: ${cloudXAd.revenue}")
}
override fun onDestroy() {
super.onDestroy()
appOpenAd.destroy()
}
}Use App Open ads sparingly and only at natural app-open or app-resume transitions. Avoid showing one while the user is already interacting with app content.
Ad readiness
isAdReady is true from the moment an ad loads until you show it or destroy the ad object. An ad network can stop being able to show an ad without telling the SDK. isAdReady stays true in that case, and the problem is found when you call show(). If the network does report that its ad has expired, the ad is no longer ready.
- If you call
show()on an ad the network can no longer show,onAdDisplayFailedfires and the ad is no longer ready. Callload()to get a new ad. - In that case, if CloudX has enabled show recovery for your app and ad unit, the SDK loads a replacement and shows it instead. You receive the replacement’s display and revenue callbacks, and no
onAdDisplayFailed. If an expired-ad replacement is already loading, the SDK uses it, andonExpiredAdReloadedfires before it is shown. If no replacement loads, or none is ready within the time limit CloudX sets,onAdDisplayFailedfires. - If you call
load()while an ad is ready, no new request starts.onAdLoadedfires at once with that ad. - A
load()call while an ad is showing runs after the ad closes. Aload()call whileshow()waits for a recovery replacement also runs after the show ends, and receives exactly oneonAdLoadedoronAdLoadFailed.
Expired ads
A loaded ad that is not shown before it expires is reloaded automatically on the same ad object. The current ad stays ready and can still be shown until the replacement is ready.
- To be told when a replacement is ready, set an
expirationListener. A replacement that loads on its own does not callonAdLoadedagain. - If you show the ad while the replacement loads, the replacement is kept. If it is ready when the ad closes, or no
load()comes before it is ready, it becomes ready on the ad object and theexpirationListeneris called then. If you callload()after the ad closes while the replacement is still loading, thatload()runs its own request and getsonAdLoaded, and noexpirationListenercall follows for that replacement. - If you call
load()while the expired ad is still loaded, no new request starts.onAdLoadedfires at once with the expired ad. The replacement keeps loading, and theexpirationListeneris called when it is ready. - If the replacement fails to load while the expired ad is still loaded,
onAdLoadFailedfires and the ad is no longer ready. Reload and its retries are set per ad unit by CloudX, and retries are off by default, so one no-fill ends here. This is the normal outcome, not an integration error: callload()again after a delay rather than in a tight loop.
appOpenAd.expirationListener = CloudXAdExpirationListener { expiredAd, newAd ->
Log.d("CloudX", "Expired App Open ad replaced by an ad from ${newAd.networkName}")
}appOpenAd.setExpirationListener((expiredAd, newAd) ->
Log.d("CloudX", "Expired App Open ad replaced by an ad from " + newAd.getNetworkName()));