Ad Format Integration
Here's how to integrate the supported ad formats on Android. Each ad format has its own unique characteristics and implementation details.
- App Open Ads
- Rewarded Video
- Interstitial
- Banner
- Native
App Open Ads
App open ads appear when the user opens your app or switches back to your app. They are displayed on the loading or splash screen.
Benefits
- An ad overlays the loading screen
- The unique app open ad layout offers the best user experience for this placement
- Unlock new inventory: monetize users as soon as they open your app
- Maximize demands
- Highest bidding ad creatives
- Availability of both full-screen and partial-screen ads
- Optimized user experience rendering
Implementation
Loading a new ad from OnAdLoadFailedEvent()
without delay is not recommended.
If a new ad has to be loaded immediately on OnAdLoadFailedEvent()
, then the auto-delay configuration variable must be set to true to limit ad load retries, thus avoiding continuous failed ad requests and ANR issues.
- Java
- Kotlin
// Remember to call this function before SDK init.
Yodo1MasAppOpenAd.getInstance().autoDelayIfLoadFail = true;
// Remember to call this function before SDK init.
Yodo1MasAppOpenAd.getInstance().autoDelayIfLoadFail = true
- Java
- Kotlin
// Load the ad
Yodo1MasAppOpenAd.getInstance().loadAd(MainActivity.this);
// Show the ad
boolean isLoaded = Yodo1MasAppOpenAd.getInstance().isLoaded();
if (isLoaded) {
// Show without placement
Yodo1MasAppOpenAd.getInstance().showAd(this);
// Or show with placement
Yodo1MasAppOpenAd.getInstance().showAd(this, "Your placement ID");
}
// Load the ad
Yodo1MasAppOpenAd.getInstance().loadAd(this@MainActivity)
// Show the ad
val isLoaded = Yodo1MasAppOpenAd.getInstance().isLoaded()
if (isLoaded) {
// Show without placement
Yodo1MasAppOpenAd.getInstance().showAd(this@MainActivity)
// Or show with placement
Yodo1MasAppOpenAd.getInstance().showAd(this@MainActivity, "Your placement ID")
}
Events
- Java
- Kotlin
Yodo1MasAppOpenAd.getInstance().setAdListener(new Yodo1MasAppOpenAdListener() {
@Override
public void onAppOpenAdLoaded(Yodo1MasAppOpenAd ad) {
// Ad loaded successfully
}
@Override
public void onAppOpenAdFailedToLoad(Yodo1MasAppOpenAd ad, @NonNull Yodo1MasError error) {
// Ad failed to load
}
@Override
public void onAppOpenAdOpened(Yodo1MasAppOpenAd ad) {
// Ad opened, impression recorded
}
@Override
public void onAppOpenAdFailedToOpen(Yodo1MasAppOpenAd ad, @NonNull Yodo1MasError error) {
// Ad failed to open
}
@Override
public void onAppOpenAdClosed(Yodo1MasAppOpenAd ad) {
// Ad closed
}
});
Yodo1MasAppOpenAd.getInstance().setAdListener(object : Yodo1MasAppOpenAdListener {
override fun onAppOpenAdLoaded(ad: Yodo1MasAppOpenAd) {
// Ad loaded successfully
}
override fun onAppOpenAdFailedToLoad(ad: Yodo1MasAppOpenAd, error: Yodo1MasError) {
// Ad failed to load
}
override fun onAppOpenAdOpened(ad: Yodo1MasAppOpenAd) {
// Ad opened, impression recorded
}
override fun onAppOpenAdFailedToOpen(ad: Yodo1MasAppOpenAd, error: Yodo1MasError) {
// Ad failed to open
}
override fun onAppOpenAdClosed(ad: Yodo1MasAppOpenAd) {
// Ad closed
}
})
Impression-Level User Revenue
Impression-level user revenue data allows you to access detailed revenue information for each ad impression. This data can be used to compare different sources and campaigns, and to share impression-level ad revenue data with your mobile measurement partner of choice.
You can retrieve the revenue amount in all ad lifecycle callbacks. The following example shows how to do this within a callback:
- Java
- Kotlin
Yodo1MasAppOpenAd.getInstance().setAdRevenueListener(new Yodo1MasAppOpenAdRevenueListener() {
@Override
public void onAppOpenAdPayRevenue(Yodo1MasAppOpenAd ad, Yodo1MasAdValue adValue) {
double revenue = adValue.getRevenue();
String currency = adValue.getCurrency();
String revenuePrecision = adValue.getRevenuePrecision();
}
});
Yodo1MasAppOpenAd.getInstance().setAdRevenueListener { ad, adValue ->
val revenue = adValue.revenue
val currency = adValue.currency
val revenuePrecision = adValue.revenuePrecision
}
The revenuePrecision
takes one of the following values:
- "publisher_defined": the revenue amount is the price assigned by the publisher
- "exact": the revenue amount is the result of a real-time auction
- "estimated": the revenue amount is based on Auto-CPM or FB Bidding estimates
- "": revenue and precision are not valid (for example, in test mode)
Rewarded Video Ads
Rewarded video ads enable users to earn in-app rewards by watching video ads.
Benefits
- Increase revenue with highest eCPM rates
- Increase in-app purchases
- Increase user engagement and retention
Implementation
Loading a new ad from OnAdLoadFailedEvent()
without delay is not recommended.
If a new ad has to be loaded immediately on OnAdLoadFailedEvent()
, then the auto-delay configuration variable must be set to true to limit ad load retries, thus avoiding continuous failed ad requests and ANR issues.
- Java
- Kotlin
// Remember to call this function before SDK init.
Yodo1MasRewardAd.getInstance().autoDelayIfLoadFail = true;
// Remember to call this function before SDK init.
Yodo1MasRewardAd.getInstance().autoDelayIfLoadFail = true
- Java
- Kotlin
// Load the ad
Yodo1MasRewardAd.getInstance().loadAd(MainActivity.this);
// Show the ad
boolean isLoaded = Yodo1MasRewardAd.getInstance().isLoaded();
if (isLoaded) {
// Show without placement
Yodo1MasRewardAd.getInstance().showAd(this);
// Or show with placement
Yodo1MasRewardAd.getInstance().showAd(this, "Your placement ID");
}
// Load the ad
Yodo1MasRewardAd.getInstance().loadAd(this@MainActivity)
// Show the ad
val isLoaded = Yodo1MasRewardAd.getInstance().isLoaded()
if (isLoaded) {
// Show without placement
Yodo1MasRewardAd.getInstance().showAd(this@MainActivity)
// Or show with placement
Yodo1MasRewardAd.getInstance().showAd(this@MainActivity, "Your placement ID")
}
Events
- Java
- Kotlin
Yodo1MasRewardAd.getInstance().setAdListener(new Yodo1MasRewardAdListener() {
@Override
public void onRewardAdLoaded(Yodo1MasRewardAd ad) {
// Ad loaded successfully
}
@Override
public void onRewardAdFailedToLoad(Yodo1MasRewardAd ad, @NonNull Yodo1MasError error) {
// Ad failed to load
}
@Override
public void onRewardAdOpened(Yodo1MasRewardAd ad) {
// Ad opened
}
@Override
public void onRewardAdFailedToOpen(Yodo1MasRewardAd ad, @NonNull Yodo1MasError error) {
// Ad failed to open
}
@Override
public void onRewardAdClosed(Yodo1MasRewardAd ad) {
// Ad closed
}
@Override
public void onRewardAdEarned(Yodo1MasRewardAd ad) {
// User earned the reward
}
});
Yodo1MasRewardAd.getInstance().setAdListener(object : Yodo1MasRewardAdListener {
override fun onRewardAdLoaded(ad: Yodo1MasRewardAd) {
// Ad loaded successfully
}
override fun onRewardAdFailedToLoad(ad: Yodo1MasRewardAd, error: Yodo1MasError) {
// Ad failed to load
}
override fun onRewardAdOpened(ad: Yodo1MasRewardAd) {
// Ad opened
}
override fun onRewardAdFailedToOpen(ad: Yodo1MasRewardAd, error: Yodo1MasError) {
// Ad failed to open
}
override fun onRewardAdClosed(ad: Yodo1MasRewardAd) {
// Ad closed
}
override fun onRewardAdEarned(ad: Yodo1MasRewardAd) {
// User earned the reward
}
})
Impression-Level User Revenue
- Java
- Kotlin
Yodo1MasRewardAd.getInstance().setAdRevenueListener(new Yodo1MasRewardAdRevenueListener() {
@Override
public void onRewardAdPayRevenue(Yodo1MasRewardAd ad, Yodo1MasAdValue adValue) {
double revenue = adValue.getRevenue();
String currency = adValue.getCurrency();
String revenuePrecision = adValue.getRevenuePrecision();
}
});
Yodo1MasRewardAd.getInstance().setAdRevenueListener { ad, adValue ->
val revenue = adValue.revenue
val currency = adValue.currency
val revenuePrecision = adValue.revenuePrecision
}
The revenuePrecision
takes one of the following values:
- "publisher_defined": the revenue amount is the price assigned by the publisher
- "exact": the revenue amount is the result of a real-time auction
- "estimated": the revenue amount is based on Auto-CPM or FB Bidding estimates
- "": revenue and precision are not valid (for example, in test mode)
Interstitial Ads
Interstitial ads are full-screen ads that appear at natural transition points in your app.
Benefits
- Engaging full-screen content
- Media content can be static, video-based or interactive
- Positive UX when placed at natural transition points
Implementation
Loading a new ad from OnAdLoadFailedEvent()
without delay is not recommended.
If a new ad has to be loaded immediately on OnAdLoadFailedEvent()
, then the auto-delay configuration variable must be set to true to limit ad load retries, thus avoiding continuous failed ad requests and ANR issues.
- Java
- Kotlin
// Remember to call this function before SDK init.
Yodo1MasInterstitialAd.getInstance().autoDelayIfLoadFail = true;
// Remember to call this function before SDK init.
Yodo1MasInterstitialAd.getInstance().autoDelayIfLoadFail = true
- Java
- Kotlin
// Load the ad
Yodo1MasInterstitialAd.getInstance().loadAd(MainActivity.this);
// Show the ad
boolean isLoaded = Yodo1MasInterstitialAd.getInstance().isLoaded();
if (isLoaded) {
// Show without placement
Yodo1MasInterstitialAd.getInstance().showAd(this);
// Or show with placement
Yodo1MasInterstitialAd.getInstance().showAd(this, "Your placement ID");
}
// Load the ad
Yodo1MasInterstitialAd.getInstance().loadAd(this@MainActivity)
// Show the ad
val isLoaded = Yodo1MasInterstitialAd.getInstance().isLoaded()
if (isLoaded) {
// Show without placement
Yodo1MasInterstitialAd.getInstance().showAd(this@MainActivity)
// Or show with placement
Yodo1MasInterstitialAd.getInstance().showAd(this@MainActivity, "Your placement ID")
}
Events
- Java
- Kotlin
Yodo1MasInterstitialAd.getInstance().setAdListener(new Yodo1MasInterstitialAdListener() {
@Override
public void onInterstitialAdLoaded(Yodo1MasInterstitialAd ad) {
// Ad loaded successfully
}
@Override
public void onInterstitialAdFailedToLoad(Yodo1MasInterstitialAd ad, @NonNull Yodo1MasError error) {
// Ad failed to load
}
@Override
public void onInterstitialAdOpened(Yodo1MasInterstitialAd ad) {
// Ad opened
}
@Override
public void onInterstitialAdFailedToOpen(Yodo1MasInterstitialAd ad, @NonNull Yodo1MasError error) {
// Ad failed to open
}
@Override
public void onInterstitialAdClosed(Yodo1MasInterstitialAd ad) {
// Ad closed
}
});
Yodo1MasInterstitialAd.getInstance().setAdListener(object : Yodo1MasInterstitialAdListener {
override fun onInterstitialAdLoaded(ad: Yodo1MasInterstitialAd) {
// Ad loaded successfully
}
override fun onInterstitialAdFailedToLoad(ad: Yodo1MasInterstitialAd, error: Yodo1MasError) {
// Ad failed to load
}
override fun onInterstitialAdOpened(ad: Yodo1MasInterstitialAd) {
// Ad opened
}
override fun onInterstitialAdFailedToOpen(ad: Yodo1MasInterstitialAd, error: Yodo1MasError) {
// Ad failed to open
}
override fun onInterstitialAdClosed(ad: Yodo1MasInterstitialAd) {
// Ad closed
}
})
Impression-Level User Revenue
- Java
- Kotlin
Yodo1MasInterstitialAd.getInstance().setAdRevenueListener(new Yodo1MasInterstitialAdRevenueListener() {
@Override
public void onInterstitialAdPayRevenue(Yodo1MasInterstitialAd ad, Yodo1MasAdValue adValue) {
double revenue = adValue.getRevenue();
String currency = adValue.getCurrency();
String revenuePrecision = adValue.getRevenuePrecision();
}
});
Yodo1MasInterstitialAd.getInstance().setAdRevenueListener { ad, adValue ->
val revenue = adValue.revenue
val currency = adValue.currency
val revenuePrecision = adValue.revenuePrecision
}
The revenuePrecision
takes one of the following values:
- "publisher_defined": the revenue amount is the price assigned by the publisher
- "exact": the revenue amount is the result of a real-time auction
- "estimated": the revenue amount is based on Auto-CPM or FB Bidding estimates
- "": revenue and precision are not valid (for example, in test mode)
Banner Ads
Banner ads are rectangular ads that occupy a portion of the app's layout and can refresh automatically.
Supported Sizes
- 320×50 (Standard Banner)
- 320×100 (Large Banner)
- 300×250 (IAB Medium Rectangle)
- Adaptive Banner
- Smart Banner
Implementation
Loading a new ad from OnAdLoadFailedEvent()
without delay is not recommended.
If a new ad has to be loaded immediately on OnAdLoadFailedEvent()
, then the auto-delay configuration variable must be set to true to limit ad load retries, thus avoiding continuous failed ad requests and ANR issues.
- Java
- Kotlin
// Remember to call this function before SDK init.
Yodo1MasBannerAd.getInstance().autoDelayIfLoadFail = true;
// Remember to call this function before SDK init.
Yodo1MasBannerAd.getInstance().autoDelayIfLoadFail = true
- Java
- Kotlin
// XML Layout
<com.yodo1.mas.banner.Yodo1MasBannerAdView
android:id="@+id/banner"
android:layout_width="320dp"
android:layout_height="50dp"
masads:adSize="Banner" />
// Java Code
Yodo1MasBannerAdView bannerAdView = findViewById(R.id.banner);
bannerAdView.loadAd();
// Or create programmatically
Yodo1MasBannerAdView bannerAdView = new Yodo1MasBannerAdView(this);
bannerAdView.setAdSize(Yodo1MasBannerAdSize.Banner);
layout.addView(bannerAdView, new LayoutParams(320, 50));
bannerAdView.loadAd();
// XML Layout
<com.yodo1.mas.banner.Yodo1MasBannerAdView
android:id="@+id/banner"
android:layout_width="320dp"
android:layout_height="50dp"
masads:adSize="Banner" />
// Kotlin Code
val bannerAdView: Yodo1MasBannerAdView = findViewById(R.id.banner)
bannerAdView.loadAd()
// Or create programmatically
val bannerAdView = Yodo1MasBannerAdView(this)
bannerAdView.setAdSize(Yodo1MasBannerAdSize.Banner)
layout.addView(bannerAdView, LayoutParams(320, 50))
bannerAdView.loadAd()
Events
- Java
- Kotlin
bannerAdView.setAdListener(new Yodo1MasBannerAdListener() {
@Override
public void onBannerAdLoaded(Yodo1MasBannerAdView bannerAdView) {
// Ad loaded successfully
}
@Override
public void onBannerAdFailedToLoad(Yodo1MasBannerAdView bannerAdView, @NonNull Yodo1MasError error) {
// Ad failed to load
}
@Override
public void onBannerAdOpened(Yodo1MasBannerAdView bannerAdView) {
// Ad opened
}
@Override
public void onBannerAdFailedToOpen(Yodo1MasBannerAdView bannerAdView, @NonNull Yodo1MasError error) {
// Ad failed to open
}
@Override
public void onBannerAdClosed(Yodo1MasBannerAdView bannerAdView) {
// Ad closed
}
});
bannerAdView.setAdListener(object : Yodo1MasBannerAdListener {
override fun onBannerAdLoaded(bannerAdView: Yodo1MasBannerAdView) {
// Ad loaded successfully
}
override fun onBannerAdFailedToLoad(bannerAdView: Yodo1MasBannerAdView, error: Yodo1MasError) {
// Ad failed to load
}
override fun onBannerAdOpened(bannerAdView: Yodo1MasBannerAdView) {
// Ad opened
}
override fun onBannerAdFailedToOpen(bannerAdView: Yodo1MasBannerAdView, error: Yodo1MasError) {
// Ad failed to open
}
override fun onBannerAdClosed(bannerAdView: Yodo1MasBannerAdView) {
// Ad closed
}
})
Impression-Level User Revenue
- Java
- Kotlin
bannerAdView.setAdRevenueListener(new Yodo1MasBannerAdRevenueListener() {
@Override
public void onBannerAdPayRevenue(Yodo1MasBannerAdView view, Yodo1MasAdValue adValue) {
double revenue = adValue.getRevenue();
String currency = adValue.getCurrency();
String revenuePrecision = adValue.getRevenuePrecision();
}
});
bannerAdView.setAdRevenueListener { view, adValue ->
val revenue = adValue.revenue
val currency = adValue.currency
val revenuePrecision = adValue.revenuePrecision
}
The revenuePrecision
takes one of the following values:
- "publisher_defined": the revenue amount is the price assigned by the publisher
- "exact": the revenue amount is the result of a real-time auction
- "estimated": the revenue amount is based on Auto-CPM or FB Bidding estimates
- "": revenue and precision are not valid (for example, in test mode)
Native Ads
Native ads allow you to customize the ad experience by blending it directly into your app's UI.
Benefits
- Better eCPMs than Banners
- Positive impact on retention
- Customizable to match your app's UI
Implementation
Loading a new ad from OnAdLoadFailedEvent()
without delay is not recommended.
If a new ad has to be loaded immediately on OnAdLoadFailedEvent()
, then the auto-delay configuration variable must be set to true to limit ad load retries, thus avoiding continuous failed ad requests and ANR issues.
- Java
- Kotlin
// Remember to call this function before SDK init.
Yodo1MasNativeAd.getInstance().autoDelayIfLoadFail = true;
// Remember to call this function before SDK init.
Yodo1MasNativeAd.getInstance().autoDelayIfLoadFail = true
- Java
- Kotlin
// XML Layout
<com.yodo1.mas.nativeads.Yodo1MasNativeAdView
android:id="@+id/native_ad"
android:layout_width="match_parent"
android:layout_height="300dp"/>
// Java Code
Yodo1MasNativeAdView nativeAdView = findViewById(R.id.native_ad);
nativeAdView.loadAd();
// Or create programmatically
Yodo1MasNativeAdView nativeAdView = new Yodo1MasNativeAdView(this);
layout.addView(nativeAdView, new LayoutParams(LayoutParams.MATCH_PARENT, 300));
nativeAdView.loadAd();
// XML Layout
<com.yodo1.mas.nativeads.Yodo1MasNativeAdView
android:id="@+id/native_ad"
android:layout_width="match_parent"
android:layout_height="300dp"/>
// Kotlin Code
val nativeAdView: Yodo1MasNativeAdView = findViewById(R.id.native_ad)
nativeAdView.loadAd()
// Or create programmatically
val nativeAdView = Yodo1MasNativeAdView(this)
layout.addView(nativeAdView, LayoutParams(LayoutParams.MATCH_PARENT, 300))
nativeAdView.loadAd()
Events
- Java
- Kotlin
nativeAdView.setAdListener(new Yodo1MasNativeAdListener() {
@Override
public void onNativeAdLoaded(Yodo1MasNativeAdView nativeAdView) {
// Ad loaded successfully
}
@Override
public void onNativeAdFailedToLoad(Yodo1MasNativeAdView nativeAdView, @NonNull Yodo1MasError error) {
// Ad failed to load
}
});
nativeAdView.setAdListener(object : Yodo1MasNativeAdListener {
override fun onNativeAdLoaded(nativeAdView: Yodo1MasNativeAdView) {
// Ad loaded successfully
}
override fun onNativeAdFailedToLoad(nativeAdView: Yodo1MasNativeAdView, error: Yodo1MasError) {
// Ad failed to load
}
})
Impression-Level User Revenue
- Java
- Kotlin
nativeAdView.setAdRevenueListener(new Yodo1MasNativeAdRevenueListener() {
@Override
public void onNativeAdPayRevenue(Yodo1MasNativeAdView view, Yodo1MasAdValue adValue) {
double revenue = adValue.getRevenue();
String currency = adValue.getCurrency();
String revenuePrecision = adValue.getRevenuePrecision();
}
});
nativeAdView.setAdRevenueListener { view, adValue ->
val revenue = adValue.revenue
val currency = adValue.currency
val revenuePrecision = adValue.revenuePrecision
}
The revenuePrecision
takes one of the following values:
- "publisher_defined": the revenue amount is the price assigned by the publisher
- "exact": the revenue amount is the result of a real-time auction
- "estimated": the revenue amount is based on Auto-CPM or FB Bidding estimates
- "": revenue and precision are not valid (for example, in test mode)
Best Practices
- Preload Ads: Always preload ads before showing them to ensure they're ready when needed.
- Use Placements: Set placement names when showing ads to track performance in the dashboard.
- Handle Failures: Wait at least 10 seconds before retrying after a failed load.
- User Experience: Place ads at natural transition points in your app.
- Error Handling: Always implement proper error handling in the event callbacks.