Load Ads
Creating Interstitial & Rewarded Ads
To show an interstitial or rewarded ad, create a variable to hold a reference to either the Interstitial or Rewarded Mediation Ad:
val heliumInterstitialAd: HeliumInterstitialAd
val heliumRewardedAd: HeliumRewardedAd
private HeliumInterstitialAd heliumInterstitialAd;
private HeliumRewardedAd heliumRewardedAd;
Using the Placement Name set up on your dashboard, get an instance of a Mediation Ad:
heliumInterstitialAd = HeliumInterstitialAd(MYHELIUMPLACEMENT1, heliumInterstitialAdListener)
heliumRewardedAd = HeliumRewardedAd(MYHELIUMPLACEMENT2, heliumRewardedAdListener)
heliumInterstitialAd = new HeliumInterstitialAd(MYHELIUMPLACEMENT1, heliumInterstitialAdListener);
heliumRewardedAd = new HeliumRewardedAd(MYHELIUMPLACEMENT2, heliumRewardedAdListener);
In the above examples, weโre passing in the heliumInterstitialAdListener
object and heliumRewardedAdListener
to act as delegates/listeners and receive notifications about the SDK ad activity. See Android Delegate Usage for more details.
Loading Interstitial & Rewarded Ads
Create an instance for each Placement Name you want to use. Then, make the call to load the ad:
heliumInterstitialAd.load()
heliumRewardedAd.load()
heliumInterstitialAd.load();
heliumRewardedAd.load();
The loadID
can be found in the listener's load callback.
For Mediation SDK 4.0.0:
load()
does not return aString
For Mediation SDK 3.0.0:
load()
returns aString
representing the load request identifier. This return value is optional to consume.
Creating Banner Ads
There are two ways to create banners on Android:
- programmatically
- XML
Note
The following banner sizes can be passed down. Some partners may not fill for some banner sizes.
Banner Enum | Dimensions (Width & Height) |
---|---|
Standard | 320 x 50 |
Medium | 300 x 250 |
Leaderboard | 728 x 90 |
Create Banner Ads Programmatically
- Declare a variable to hold a reference to the Banner Mediation Ad.
- Supply the corresponding Placement Name and Banner Size
/*
The following Banner enum Sizes can be passed down:
HeliumBannerAd.HeliumBannerSize.STANDARD
HeliumBannerAd.HeliumBannerSize.MEDIUM
HeliumBannerAd.HeliumBannerSize.LEADERBOARD
*/
val bannerSize = HeliumBannerAd.HeliumBannerSize.STANDARD
val heliumBannerAd = new HeliumBannerAd(context, placementName, bannerSize, bannerListener)
/*
The following Banner enum Sizes can be passed down:
HeliumBannerAd.HeliumBannerSize.STANDARD
HeliumBannerAd.HeliumBannerSize.MEDIUM
HeliumBannerAd.HeliumBannerSize.LEADERBOARD
*/
HeliumBannerAd.HeliumBannerSize bannerSize = HeliumBannerAd.HeliumBannerSize.STANDARD;
HeliumBannerAd heliumBannerAd = new HeliumBannerAd(context, placementName, bannerSize, bannerListener);
Creating Banner Ads in an XML Layout
- Set the
HeliumBannerAd
in the layout where you want to display the banner. - Set the
app:heliumBannerSize
to either STANDARD, MEDIUM, or LEADERBOARD. - Set the
app:heliumPlacementName
for the banner placement that you have in the dashboard.
...
<com.chartboost.heliumsdk.ad.HeliumBannerAd
android:id="@+id/bannerAd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:layout_height="50dp"
app:heliumBannerSize="STANDARD"
app:heliumPlacementName="PlacementName" />
...
Loading Banner Ads
For Mediation SDK 3.0.0:
load()
returns aString
representing the load request identifier. This return value is optional to consume.- Banners are now automatically shown. Add this banner view to the view hierarchy and the ads will automatically be shown.
You will need to create an ad instance for each placement name you want to use. Finally, make the call to load the ad:
// load() returns a String representing the load request identifier.
heliumBannerAd.load()
// load() returns a String representing the load request identifier.
heliumBannerAd.load();
Clearing Loaded Ads
Clearing loaded ads may be necessary on existing placements to request another ad (i.e. for an in-house programmatic auction).
Clearing Interstitial and Rewarded Ads
heliumInterstitialAd.clearLoaded()
heliumRewardedAd.clearLoaded()
heliumInterstitialAd.clearLoaded();
heliumRewardedAd.clearLoaded();
Clearing Banner Ads
For Mediation SDK 3.0.0 on banners:
- Call
clearAd()
to clear the currently displayed and cached banner ad.
// To clear currently showing and any cached ad loaded for auto refresh.
heliumBannerAd.clearAd()
// To clear currently showing and any cached ad loaded for auto refresh.
heliumBannerAd.clearAd();
- The 3.x.x
clearAd
and 2.x.xclearLoaded
API returns a boolean and indicates if the ad object has been cleared and is ready for another load call.
Updated 4 months ago