Skip to main content
Version: Next

Advertising

Code and functions

Initialize

danger

if use Advertising module necessarily add com.google.android.gms.ads.APPLICATION_ID in your manifest even if not going to use AdMob(just add test id = ca-app-pub-3940256099942544~3347511713)

<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>

add to your code

import com.platform101xp.advertising.interfaces.AdvertisingListener;

and create AdvertisingListener and add Platform101XP.setAdvertisingListener(advertisingListener); before init SDK in your's onCreate in MainActivity

// Java
AdvertisingListener advertisingListener = new AdvertisingListener() {
@Override
public void onRewardedInterstitialAdShowed(int amount, @androidx.annotation.Nullable String name, @androidx.annotation.Nullable Platform101XPError error) { }
@Override
public void onRewardedInterstitialAdLoaded(@androidx.annotation.Nullable Platform101XPError error) {}
@Override
public void onInterstitialAdShowed(@androidx.annotation.Nullable Platform101XPError error) {}
@Override
public void onInterstitialAdLoaded(@androidx.annotation.Nullable Platform101XPError error) {}
@Override
public void onBannedAdShowed(@androidx.annotation.Nullable Platform101XPError error) {}
@Override
public void onAppOpenAdShowed(@androidx.annotation.Nullable Platform101XPError error) {}
@Override
public void onAppOpenAdLoaded(@androidx.annotation.Nullable Platform101XPError error) {}
@Override
public void onInitializationComplete() {}
@Override
public void onRewardedAdLoaded(@androidx.annotation.Nullable Platform101XPError error) {}
@Override
public void onRewardedAdShowed(int amount, @androidx.annotation.Nullable String name, @androidx.annotation.Nullable Platform101XPError error) {}
};
// Initialize 101XP SDK.
Platform101XP.onCreate(this);
Platform101XP.setAdvertisingListener(advertisingListener);
Platform101XP.initialize(listener);

// Kotlin
val advertisingListener: AdvertisingListener = object : AdvertisingListener {
override fun onRewardedInterstitialAdShowed(amount: Int, name: String?, error: Platform101XPError?) {}
override fun onRewardedInterstitialAdLoaded(error: Platform101XPError?) {}
override fun onInterstitialAdShowed(error: Platform101XPError?) {}
override fun onInterstitialAdLoaded(error: Platform101XPError?) {}
override fun onBannedAdShowed(error: Platform101XPError?) {}
override fun onAppOpenAdShowed(error: Platform101XPError?) {}
override fun onAppOpenAdLoaded(error: Platform101XPError?) {}
override fun onInitializationComplete() {}
override fun onRewardedAdLoaded(error: Platform101XPError?) {}
override fun onRewardedAdShowed(amount: Int, name: String?, error: Platform101XPError?) {}
}
// Initialize 101XP SDK.
Platform101XP.onCreate(this)
Platform101XP.setAdvertisingListener(advertisingListener)
Platform101XP.initialize(listener)

Functions to call Ad

Reward Ads

// Java
Platform101XP.loadRewardedAd("AdUnitId");

// Kotlin
Platform101XP.loadRewardedAd("AdUnitId")

to load Reward Ad call Platform101XP.loadRewardedAd with param AdUnitId or 'null' if your want load default Ad for IronSource or for AdMob specified in your manifest

after load Ad SDK call in AdvertisingListener onRewardedAdLoaded(Platform101XPError error)

// Java
@Override
public void onRewardedAdLoaded(@androidx.annotation.Nullable Platform101XPError error) {}

// Kotlin
override fun onRewardedAdLoaded(error: Platform101XPError?) {}

for show Reward Ad call Platform101XP.showRewardedAd

// Java
Platform101XP.showRewardedAd("AdUnitId");

// Kotlin
Platform101XP.showRewardedAd("AdUnitId")

and call onRewardedAdShowed(int amount, String name, Platform101XPError error) after users will review Reward Ads and should be rewarded him

// Java
@Override
public void onRewardedAdShowed(int amount, @androidx.annotation.Nullable String name, @androidx.annotation.Nullable Platform101XPError error) {}

// Kotlin
override fun onRewardedAdShowed(amount: Int, name: String?, error: Platform101XPError?) {}

for check availability Reward Ad use (begin load, after check)

// Java
boolean b = Platform101XP.isRewardedVideoLoaded()

// Kotlin
val b = Platform101XP.isRewardedVideoLoaded()

Interstitial Ads

// Java
Platform101XP.loadInterstitialAd("AdUnitId");

// Kotlin
Platform101XP.loadInterstitialAd("AdUnitId")

to call Interstitial Ad call Platform101XP.loadInterstitialAd with param AdUnitId or 'null' if your want load default Ad for IronSource or for AdMob specified in your manifest

after load Ad SDK call in AdvertisingListener onInterstitialAdLoaded(Platform101XPError error)

// Java
@Override
public void onInterstitialAdLoaded(@androidx.annotation.Nullable Platform101XPError error) {}

// Kotlin
override fun onInterstitialAdLoaded(error: Platform101XPError?) {}

for show Interstitial Ad call Platform101XP.showInterstitialAd

// Java
Platform101XP.showInterstitialAd("AdUnitId");

// Kotlin
Platform101XP.showInterstitialAd("AdUnitId")

and call onInterstitialAdShowed(Platform101XPError error) after users will review Interstitial Ads

// Java
@Override
public void onInterstitialAdShowed(@androidx.annotation.Nullable Platform101XPError error) {}

// Kotlin
override fun onInterstitialAdShowed(error: Platform101XPError?) {}

for check availability Interstitial Ad use (begin load, after check)

// Java
boolean b = Platform101XP.isInterstitialAdLoaded()

// Kotlin
val b = Platform101XP.isInterstitialAdLoaded()

Banner Ads

// Java
Platform101XP.showBannerAd("AdUnitId");

// Kotlin
Platform101XP.showBannerAd("AdUnitId")

to call Banner Ad call Platform101XP.showBannerAd with param AdUnitId or 'null' if your want load default Ad for IronSource or for AdMob specified in your manifest

after call showBannerAd and show Ad sdk call onBannedAdShowed(Platform101XPError error) after users will review Banner Ads

// Java
@Override
public void onBannedAdShowed(@androidx.annotation.Nullable Platform101XPError error) {}

// Kotlin
override fun onBannedAdShowed(error: Platform101XPError?) {}

and to hide Banner Ad call Platform101XP.hideBannerAd

// Java
Platform101XP.hideBannerAd();

// Kotlin
Platform101XP.hideBannerAd()

for check availability Banner Ad use (only ironSource, AdMob always return false)

// Java
boolean b = Platform101XP.isBannerAdLoaded();

// Kotlin
val b = Platform101XP.isBannerAdLoaded()

Reward Interstitial Ads - (only AdMob)

// Java
Platform101XP.loadRewardedInterstitialAd("AdUnitId");

// Kotlin
Platform101XP.loadRewardedInterstitialAd("AdUnitId")

to call Reward Interstitial Ad call Platform101XP.loadRewardedInterstitialAd with param AdUnitId or 'null' if your want load specified Ad in your manifest for AdMob

after load Ad SDK call in AdvertisingListener onRewardedInterstitialAdLoaded(Platform101XPError error)

// Java
@Override
public void onRewardedInterstitialAdLoaded(@androidx.annotation.Nullable Platform101XPError error) {}

// Kotlin
override fun onRewardedInterstitialAdLoaded(error: Platform101XPError?) {}

for show Reward Interstitial Ad call Platform101XP.showRewardedInterstitialAd

// Java
Platform101XP.showRewardedInterstitialAd("AdUnitId");

// Kotlin
Platform101XP.showRewardedInterstitialAd("AdUnitId")

and call onRewardedInterstitialAdShowed(int amount, String name, Platform101XPError error) after users will review Reward Interstitial Ads and should be rewarded him

// Java
@Override
public void onRewardedInterstitialAdShowed(int amount, @androidx.annotation.Nullable String name, @androidx.annotation.Nullable Platform101XPError error) {}

// Kotlin
override fun onRewardedInterstitialAdShowed(amount: Int, name: String?, error: Platform101XPError?) {}

AppOpen Ads - (only AdMob)

Not manual call, show after Open Application and after Resume Application if spend delay time (if your set with param in manifest else always after resume) after load Ads SDK call in AdvertisingListener onAppOpenAdLoaded(Platform101XPError error)

// Java
@Override
public void onAppOpenAdLoaded(@androidx.annotation.Nullable Platform101XPError error) {}

// Kotlin
override fun onAppOpenAdLoaded(error: Platform101XPError?) {}

and after show Ads call in AdvertisingListener onAppOpenAdShowed(Platform101XPError error)

// Java
@Override
public void onAppOpenAdShowed(@androidx.annotation.Nullable Platform101XPError error) {}

// Kotlin
override fun onAppOpenAdShowed(error: Platform101XPError?) {}

AdMob Google Ad

Integration

Add your AdMob app ID identified in the AdMob UI to your app's AndroidManifest.xml file. To do so, add a <meta-data\> tag with android:name="com.google.android.gms.ads.APPLICATION_ID". You can find your app ID in the AdMob UI. For android:value, insert your own AdMob app ID, surrounded by quotation marks.

<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>

and enable AdMob in SDK

<meta-data
android:name="com.platform101xp.sdk.admob_enabled"
android:value="@bool/admob_enabled"/>

@bool/admob_enabled - switching-on of the AdMob functions, default FALSE

App Open Ads

App open ads are a special ad format intended for publishers wishing to monetize their app load screens. App open ads can be closed at any time, and are designed to be shown when your users bring your app to the foreground. App open ads automatically show a small branding area so users know they're in your app. Automatically shown when conditions are met.

<meta-data
android:name="com.platform101xp.sdk.gms_appopen_ad_unit_id"
android:value="@string/gms_appopen_ad_unit_id"/>
<meta-data
android:name="com.platform101xp.sdk.appopen_ad_time"
android:value="@integer/appopen_ad_time"/>
<meta-data
android:name="com.platform101xp.sdk.appopen_ad_orientation"
android:value="@string/appopen_ad_orientation"/>

App open ads help you monetize your app's loading screen, when the app first launches and during app switches (onResume).

@string/gms_appopen_ad_unit_id - AdUnitId App Open

@integer/appopen_ad_time - App Open delay in minutes between impressions Ad after call onResume Android ActivityLifecycle, in first open application show always

@string/appopen_ad_orientation - App Open screen orientation (support value: "portrait"|"landscape") default: "landscape"

Banner ads occupy a spot within an app's layout, either at the top or bottom of the device screen. They stay on screen while users are interacting with the app, and can refresh automatically after a certain period of time.

<meta-data
android:name="com.platform101xp.sdk.banner_ad_unit_id"
android:value="@string/banner_ad_unit_id"/>
<meta-data
android:name="com.platform101xp.sdk.banner_ad_position_vertical"
android:value="@string/banner_ad_position_vertical"/>
<meta-data
android:name="com.platform101xp.sdk.banner_ad_position_horizontal"
android:value="@string/banner_ad_position_horizontal"/>
<meta-data
android:name="com.platform101xp.sdk.banner_ad_size"
android:value="@string/banner_ad_size"/>

@string/gms_appopen_ad_unit_id - AdUnitId Banner Ads

@string/banner_ad_position_vertical - vertical position Banner Ads (support value: "top"|"middle"|"bottom") default: "top"

@string/banner_ad_position_horizontal - horizontal position Banner Ads (support value: "left"|"center"|"right") default: "center"

@string/banner_ad_size - Banner Ads Size (support value: "banner"|"large"|"rectangle"|"smart") default: "banner"

Size in dp (WxH)Descriptionbanner_ad_size
320x50Bannerbanner
320x100Large Bannerlarge
300x250IAB Medium Rectanglerectangle
Screen width x (32 or 50 or 90)Smart bannersmart

Interstitial ads

Interstitial ads are full-screen ads that cover the interface of their host app. They're typically displayed at natural transition points in the flow of an app, such as between activities or during the pause between levels in a game. When an app shows an interstitial ad, the user has the choice to either tap on the ad and continue to its destination or close it and return to the app.

<meta-data
android:name="com.platform101xp.sdk.interstitial_ad_unit_id"
android:value="@string/interstitial_ad_unit_id"/>

@string/interstitial_ad_unit_id - AdUnitId Interstitial ads

Rewarded ads

<meta-data
android:name="com.platform101xp.sdk.reward_ad_unit_id"
android:value="@string/reward_ad_unit_id"/>

@string/reward_ad_unit_id - AdUnitId Rewarded ads

Rewarded interstitial

Rewarded interstitial is a type of incentivized ad format that lets you offer rewards for ads that appear automatically during natural app transitions. Unlike rewarded ads, users aren't required to opt in to view a rewarded interstitial.

<meta-data
android:name="com.platform101xp.sdk.gms_rewardinterstitial_ad_unit_id"
android:value="@string/gms_rewardinterstitial_ad_unit_id"/>

@string/gms_rewardinterstitial_ad_unit_id - AdUnitId Rewarded interstitial ads

Targeting

source additional info

<meta-data
android:name="com.platform101xp.sdk.tag_for_child_directed_treatment"
android:value="@string/tag_for_child_directed_treatment"/>
<meta-data
android:name="com.platform101xp.sdk.tag_for_under_age_of_consent"
android:value="@string/tag_for_under_age_of_consent"/>
<meta-data
android:name="com.platform101xp.sdk.max_ad_content_rating"
android:value="@string/max_ad_content_rating"/>
<meta-data
android:name="com.platform101xp.sdk.test_device_ids_enabled"
android:value="@bool/test_device_ids_enabled"/>
<meta-data
android:name="com.platform101xp.sdk.admob_debug_geography"
android:value="@string/admob_debug_geography"/>

Child-directed setting

For purposes of the Children's Online Privacy Protection Act (COPPA), there is a setting called "tag for child-directed treatment". By setting this tag, you certify that this notification is accurate and you are authorized to act on behalf of the owner of the app. You understand that abuse of this setting may result in termination of your Google account.

As an app developer, you can indicate whether you want Google to treat your content as child-directed when you make an ad request. If you indicate that you want Google to treat your content as child-directed, we take steps to disable IBA and remarketing ads on that ad request.

@string/tag_for_child_directed_treatment - Child-directed setting (support value: "true"|"false"|"unspecified") default: not set param

TAGDescriptionvalue
TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUEindicate that you want your content treated as child-directed for purposes of COPPA. This will prevent the transmission of the Android advertising identifier (AAID).true
TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSEindicate that you don't want your content treated as child-directed for purposes of COPPA.false
TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIEDif you don't want to indicate how you would like your content treated with respect to COPPA in ad requests.unspecified

Users under the age of consent

You can mark your ad requests to receive treatment for users in the European Economic Area (EEA) under the age of consent. This feature is designed to help facilitate compliance with the General Data Protection Regulation (GDPR). Note that you may have other legal obligations under GDPR. Please review the European Union’s guidance and consult with your own legal counsel. Please remember that Google's tools are designed to facilitate compliance and do not relieve any particular publisher of its obligations under the law.

When using this feature, a Tag For Users under the Age of Consent in Europe (TFUA) parameter will be included in the ad request. This parameter disables personalized advertising, including remarketing, for all ad requests. It also disables requests to third-party ad vendors, such as ad measurement pixels and third-party ad servers.

@string/tag_for_child_directed_treatment - Users under the age of consent setting (support value: "true"|"false"|"unspecified") default: not set param

TAGDescriptionvalue
TAG_FOR_UNDER_AGE_OF_CONSENT_TRUEindicate that you want the ad request to receive treatment for users in the European Economic Area (EEA) under the age of consent. This will also prevent the transmission of the Android advertising identifier (AAID).true
TAG_FOR_UNDER_AGE_OF_CONSENT_FALSEindicate that you want the ad request to not receive treatment for users in the European Economic Area (EEA) under the age of consent.false
TAG_FOR_UNDER_AGE_OF_CONSENT_UNSPECIFIEDindicate that you have not specified whether the ad request should receive treatment for users in the European Economic Area (EEA)unspecified

Ad content filtering

To comply with Google Play's Inappropriate Ads Policy that includes associated offers within an ad, all ads and their associated offers shown within your app must be appropriate for the content rating of your app, even if the content by itself is otherwise compliant with Google Play's policies.

Tools like maximum ad content rating can help you have more control over the content of the ads shown to your users. You can set a maximum content rating to help compliance with platform policies.

@string/max_ad_content_rating - Ad content filtering setting (support value: "G"|"PG"|"T"|"MA"|"unspecified") default: not set param

TAGvalue
MAX_AD_CONTENT_RATING_GG
MAX_AD_CONTENT_RATING_PGPG
MAX_AD_CONTENT_RATING_TT
MAX_AD_CONTENT_RATING_MAMA
MAX_AD_CONTENT_RATING_UNSPECIFIEDUnspecified

@bool/test_device_ids_enabled - set devices is TEST mode(for tests set true), more info Learn how.

@string/admob_debug_geography - The UMP SDK provides a way to test your app's behavior as though the device was located in the EEA or UK (support value: "disabled"|"eea"|"not_eea") Note that debug settings only work on test devices. Emulators don't need to be added to your device ID list as they already have testing enabled by default.

valueDebugGeographyDescription
disabledDEBUG_GEOGRAPHY_DISABLEDDebug geography disabled.
eeaDEBUG_GEOGRAPHY_EEAGeography appears as in EEA for debug devices.
not_eeaDEBUG_GEOGRAPHY_NOT_EEAGeography appears as not in the EEA for debug devices.

Test Google Id's

Ad formatSample ad unit ID
Admob appIdca-app-pub-3940256099942544~3347511713
App Openca-app-pub-3940256099942544/9257395921
Bannerca-app-pub-3940256099942544/6300978111
Interstitialca-app-pub-3940256099942544/1033173712
Interstitial Videoca-app-pub-3940256099942544/8691691433
Rewardedca-app-pub-3940256099942544/5224354917
Rewarded Interstitialca-app-pub-3940256099942544/5354046379

IronSource

Integration

add in your manifest in application

<activity
android:name="com.ironsource.sdk.controller.ControllerActivity"
android:configChanges="orientation|screenSize"
android:hardwareAccelerated="true" />
<activity
android:name="com.ironsource.sdk.controller.InterstitialActivity"
android:configChanges="orientation|screenSize"
android:hardwareAccelerated="true"
android:theme="@android:style/Theme.Translucent" />
<activity
android:name="com.ironsource.sdk.controller.OpenUrlActivity"
android:configChanges="orientation|screenSize"
android:hardwareAccelerated="true"
android:theme="@android:style/Theme.Translucent" />
<provider
android:authorities="${applicationId}.IronsourceLifecycleProvider"
android:name="com.ironsource.lifecycle.IronsourceLifecycleProvider" />

and add IronSource AppKey

<meta-data
android:name="com.platform101xp.sdk.iron_source_app_key"
android:value="@string/iron_source_app_key"/>

@string/iron_source_app_key - App Key in IronSource Developer Panel for your project

and enable IronSource in SDK

<meta-data
android:name="com.platform101xp.sdk.iron_source_enabled"
android:value="@bool/iron_source_enabled"/>

@bool/iron_source_enabled - switching-on of the IronSource functions, default FALSE

Banner ads occupy a spot within an app's layout, either at the top or bottom of the device screen. They stay on screen while users are interacting with the app, and can refresh automatically after a certain period of time.

<meta-data
android:name="com.platform101xp.sdk.banner_ad_unit_id"
android:value="@string/banner_ad_unit_id"/>
<meta-data
android:name="com.platform101xp.sdk.banner_ad_position_vertical"
android:value="@string/banner_ad_position_vertical"/>
<meta-data
android:name="com.platform101xp.sdk.banner_ad_position_horizontal"
android:value="@string/banner_ad_position_horizontal"/>
<meta-data
android:name="com.platform101xp.sdk.banner_ad_size"
android:value="@string/banner_ad_size"/>

@string/gms_appopen_ad_unit_id - AdUnitId Banner Ads

@string/banner_ad_position_vertical - vertical position Banner Ads (support value: "top"|"middle"|"bottom") default: "top"

@string/banner_ad_position_horizontal - horizontal position Banner Ads (support value: "left"|"center"|"right") default: "center"

@string/banner_ad_size - Banner Ads Size (support value: "banner"|"large"|"rectangle"|"smart") default: "banner"

Size in dp (WxH)Descriptionbanner_ad_size
320x50Bannerbanner
320x90Large Bannerlarge
300x250IAB Medium Rectanglerectangle
If (screen width ≤ 720) 320 x 50Smart bannersmart
If (screen width > 720) 728 x 90Smart bannersmart

Interstitial ads

Interstitial ads are full-screen ads that cover the interface of their host app. They're typically displayed at natural transition points in the flow of an app, such as between activities or during the pause between levels in a game. When an app shows an interstitial ad, the user has the choice to either tap on the ad and continue to its destination or close it and return to the app.

<meta-data
android:name="com.platform101xp.sdk.interstitial_ad_unit_id"
android:value="@string/interstitial_ad_unit_id"/>

@string/interstitial_ad_unit_id - AdUnitId Interstitial ads

Rewarded ads

<meta-data
android:name="com.platform101xp.sdk.reward_ad_unit_id"
android:value="@string/reward_ad_unit_id"/>

@string/reward_ad_unit_id - AdUnitId Rewarded ads

Regulation Advanced Settings

<meta-data
android:name="com.platform101xp.sdk.is_do_not_sell"
android:value="@string/is_do_not_sell"/>
<meta-data
android:name="com.platform101xp.sdk.is_child_directed"
android:value="@string/is_child_directed"/>
<meta-data
android:name="com.platform101xp.sdk.test_device_ids"
android:value="@string/test_device_ids"/>

US Privacy compliance

LevelPlay’s mediation platform (SDK Version 6.14.0 and above) supports publishers to restrict the sale or sharing of end users personal information under U.S. state privacy laws, such as the California Privacy Rights Act (CPRA).

The notification about personal information of specific users located in Virginia or California, should be handled based on a “do not sell” setting, by setting its value to “true” or “false”.

@string/is_do_not_sell - US Privacy compliance settings (support value: "true"|"false") default: not use set this param

User-Level Settings for Child-Directed Apps with Age Gates

LevelPlay’s mediation platform (SDK Version 7.1.0+) enables publishers of child-directed apps to flag specific end-users as children, as may be permitted or required by applicable law (e.g. COPPA, GDPR, etc.). Publishers of child-directed apps are responsible for determining whether an app is permitted to flag at the end-user level or must treat all end-users as children. Publishers should consult with their legal counsel accordingly.

The indication of whether a specific end-user is a child should be done using a “is_child_directed” flag, by setting its value to “true” or “false”.

@string/is_child_directed - User-Level Settings for Child-Directed Apps with Age Gates settings (support value: "true"|"false") default: not use set this param

@string/test_device_ids - test devices ID setting set your Advertising ID or just manual set Learn how.

UMP SDK

Reset consent state

In testing your app with the UMP SDK, you might find it helpful to reset the state of the SDK so that you can simulate a user's first install experience.

Platform101XP.resetConsentInformation();