The Nexverse SDK enables you to monetize your Android application with various types of high-quality ads. This guide provides step-by-step instructions for integrating the SDK and implementing different ad formats.
Depending on the ad formats you want to support, you may need to add additional dependencies.
Video Banner Ads:
If you want to support video ads on Media3 or Exo player, you will need to add one of the following dependencies:
Media3 Dependency:
implementation("ai.nexverse:ai-nexverse-sdk-media3-extn:x.x.x") // Replace x.x.x with the latest version
ExoPlayer Dependency:
implementation("ai.nexverse:ai-nexverse-sdk-exo-extn:x.x.x") // Replace x.x.x with the latest version
info
Note Choose either Media3 or ExoPlayer based on your app’s requirements. Both libraries are not needed simultaneously. If you are not using these libraries, our SDK will utilize Android’s native media view.
accountId: This unique identifier should be obtained from your Nexverse publisher dashboard.
The SDK must be initialized before requesting any ads. This one-time initialization sets up the SDK with your account configuration and prepares it for ad delivery. It is recommended to perform this initialization in your Application class’s onCreate() method.
Create the initialization configuration:
val initInfo = InitConfig(
appContext = this,
accountId = "replace-with-actual-account-id",
shareGeoLocation = true, // Optional, set to true if you want to share user location
gdprConsent = false, // Optional, set to true if you want to share GDPR consent
tcfConsentString = "replace-with-tcf-consent-string", // Optional, required for GDPR compliance
videoPlayerProviderClass = VideoPlayerViewImpl::class.java, // Optional, for video ads
)
InitConfig initInfo = new InitConfig(
this,
"replace-with-actual-account-id",
true,
false,
"replace-with-tcf-consent-string", // Optional, required for GDPR compliance
null);
Nexverse SDK offers a comprehensive suite of ad formats to help you maximize your app’s revenue potential. Each format is designed to provide a seamless user experience while delivering effective advertising content.
Banner ads are rectangular display units that occupy a portion of your app’s layout. The SDK supports both HTML and Video banner formats. These ads can be placed at various positions within your app’s interface and can be configured to refresh automatically at specified intervals.
private var bannerView: BannerView? = null
bannerView = BannerView(
this,
CONFIG_ID,
AdSize(WIDTH, HEIGHT)
)
// Set video placement type
bannerView?.videoPlacementType = VideoPlacementType.IN_BANNER
// Set up callbacks for banner events
bannerView?.setBannerListener(object : BannerViewListener {
override fun onAdFailed(bannerView: BannerView?, exception: AdException?) {
Log.e("InAppVideoBanner", "Ad failed: ${exception?.message}")
}
override fun onAdLoaded(bannerView: BannerView?) {}
override fun onAdClicked(bannerView: BannerView?) {}
override fun onAdDisplayed(bannerView: BannerView?) {}
override fun onAdClosed(bannerView: BannerView?) {}
})
// Set up callbacks for video-specific events
bannerView?.setBannerVideoListener(object : BannerVideoListener {
override fun onVideoCompleted(bannerView: BannerView?) {
// Video playback completed
}
override fun onVideoPaused(bannerView: BannerView?) {
// Video was paused
}
override fun onVideoResumed(bannerView: BannerView?) {
// Video playback resumed
}
override fun onVideoUnMuted(bannerView: BannerView?) {
// Video was unmuted
}
override fun onVideoMuted(bannerView: BannerView?) {
// Video was muted
}
})
bannerView?.loadAd()
// Add the banner view to your layout
adWrapperView.addView(bannerView)
BannerView adView = null;
adView = new BannerView(this, CONFIG_ID, new AdSize(WIDTH, HEIGHT));
adView.setVideoPlacementType(VideoPlacementType.IN_BANNER);
adView.setBannerListener(new BannerViewListener() {
@Override
public void onAdLoaded(BannerView bannerView) {}
@Override
public void onAdDisplayed(BannerView bannerView) {}
@Override
public void onAdFailed(BannerView bannerView, AdException exception) {}
@Override
public void onAdClicked(BannerView bannerView) {}
@Override
public void onAdClosed(BannerView bannerView) {}
});
adView.setBannerVideoListener(new BannerVideoListener() {
@Override
public void onVideoCompleted(BannerView bannerView) {
// Video playback completed
}
@Override
public void onVideoPaused(BannerView bannerView) {
// Video was paused
}
@Override
public void onVideoResumed(BannerView bannerView) {
// Video playback resumed
}
@Override
public void onVideoUnMuted(BannerView bannerView) {
// Video was unmuted
}
@Override
public void onVideoMuted(BannerView bannerView) {
// Video was muted
}
});
Interstitial ads are full-screen ads that cover the interface of their host app. They’re typically displayed at natural transition points in your app’s flow, such as between levels in a game, between activities, or after completing a task. The SDK supports both display (static) and video interstitial formats, as well as a multi-format option that can handle both types.
Display interstitials show full-screen static ads that can include images and interactive elements. They typically load faster than video interstitials and are great for areas with slower internet connections.
private var adUnit: InterstitialAdUnit? = null
adUnit = InterstitialAdUnit(this, CONFIG_ID, EnumSet.of(AdUnitFormat.BANNER))
adUnit?.setInterstitialAdUnitListener(object : InterstitialAdUnitListener {
override fun onAdLoaded(interstitialAdUnit: InterstitialAdUnit?) {
adUnit?.show()
}
override fun onAdDisplayed(interstitialAdUnit: InterstitialAdUnit?) {
// Ad displayed to user
}
override fun onAdFailed(interstitialAdUnit: InterstitialAdUnit?, e: AdException?) {
// Ad failed to load
}
override fun onAdClicked(interstitialAdUnit: InterstitialAdUnit?) {
// Ad was clicked
}
override fun onAdClosed(interstitialAdUnit: InterstitialAdUnit?) {
// Ad was closed by user
}
})
adUnit?.loadAd()
InterstitialAdUnit adUnit = null;
adUnit = new InterstitialAdUnit(this, CONFIG_ID, EnumSet.of(AdUnitFormat.BANNER));
adUnit.setInterstitialAdUnitListener(new InterstitialAdUnitListener() {
@Override
public void onAdLoaded(InterstitialAdUnit interstitialAdUnit) {
adUnit.show();
}
@Override
public void onAdDisplayed(InterstitialAdUnit interstitialAdUnit) {
// Ad displayed to user
}
@Override
public void onAdFailed(InterstitialAdUnit interstitialAdUnit, AdException exception) {
// Ad failed to load
}
@Override
public void onAdClicked(InterstitialAdUnit interstitialAdUnit) {
// Ad was clicked
}
@Override
public void onAdClosed(InterstitialAdUnit interstitialAdUnit) {
// Ad was closed by user
}
});
adUnit.loadAd();
Video interstitials deliver full-screen video ad experiences. They typically have higher engagement rates and eCPMs compared to display interstitials, but may require more bandwidth and loading time.
private var adUnit: InterstitialAdUnit? = null
adUnit = InterstitialAdUnit(this, CONFIG_ID, EnumSet.of(AdUnitFormat.VIDEO))
adUnit?.setInterstitialAdUnitListener(object : InterstitialAdUnitListener {
override fun onAdLoaded(interstitialAdUnit: InterstitialAdUnit?) {
adUnit?.show()
}
override fun onAdDisplayed(interstitialAdUnit: InterstitialAdUnit?) {
// Ad displayed to user
}
override fun onAdFailed(interstitialAdUnit: InterstitialAdUnit?, e: AdException?) {
// Ad failed to load
}
override fun onAdClicked(interstitialAdUnit: InterstitialAdUnit?) {
// Ad was clicked
}
override fun onAdClosed(interstitialAdUnit: InterstitialAdUnit?) {
// Ad was closed by user
}
})
adUnit?.loadAd()
InterstitialAdUnit adUnit;
adUnit = new InterstitialAdUnit(this, CONFIG_ID, EnumSet.of(AdUnitFormat.VIDEO));
adUnit.setInterstitialAdUnitListener(new InterstitialAdUnitListener() {
@Override
public void onAdLoaded (InterstitialAdUnit interstitialAdUnit){
adUnit.show();
}
@Override
public void onAdDisplayed (InterstitialAdUnit interstitialAdUnit){
// Ad display to user
}
@Override
public void onAdFailed (InterstitialAdUnit interstitialAdUnit, AdException exception){
// Ad failed to load
}
@Override
public void onAdClicked (InterstitialAdUnit interstitialAdUnit){
// Ad was clicked
}
@Override
public void onAdClosed (InterstitialAdUnit interstitialAdUnit){
// Ad was closed by user
}
});
adUnit.loadAd();
MultiFormat interstitials provide the most flexibility by supporting both display and video ads in a single implementation. This format automatically selects the best available ad type based on:
Ad availability
Network conditions
Historical performance
User preferences
To implement a MultiFormat interstitial that can serve both video and display ads:
adUnit = new InterstitialAdUnit(this, CONFIG_ID, EnumSet.of(AdUnitFormat.VIDEO, AdUnitFormat.BANNER));
This configuration maximizes fill rate by being able to serve either ad type, while the SDK handles all the complexity of format selection and delivery. The ad type selection is optimized automatically to provide the best balance of user experience and revenue.
Native ads offer the most flexible and customizable ad experience. They allow you to match the look and feel of your app by customizing every visual element of the ad. This seamless integration can lead to better user experience and higher engagement rates. Native ads are particularly effective in content feeds, article lists, or any situation where you want the ad to feel like a natural part of your app.
Rewarded ads are a powerful monetization tool that provides value to both users and developers. They allow users to earn in-app rewards (such as virtual currency, extra lives, or premium content) in exchange for watching a video ad. This opt-in format typically sees high engagement rates and user satisfaction.
Key benefits:
Higher user engagement due to opt-in nature
Better user experience through value exchange
Increased retention through reward mechanics
Higher eCPMs compared to other ad formats
Implementation:
Create and configure the rewarded ad unit:
private var adUnit: RewardedAdUnit? = null
adUnit = RewardedAdUnit(this, CONFIG_ID)
adUnit?.setRewardedAdUnitListener(object : RewardedAdUnitListener {
override fun onAdLoaded(rewardedAdUnit: RewardedAdUnit?) {
// Ad loaded and ready to show
}
override fun onAdDisplayed(rewardedAdUnit: RewardedAdUnit?) {
// Ad displayed to user
}
override fun onAdFailed(rewardedAdUnit: RewardedAdUnit?, exception: AdException?) {
// Ad failed to load
}
override fun onAdClicked(rewardedAdUnit: RewardedAdUnit?) {
// Ad was clicked
}
override fun onAdClosed(rewardedAdUnit: RewardedAdUnit?) {
// Ad was closed by user
}
override fun onReward(rewardedAdUnit: RewardedAdUnit?, reward: Reward?) {
// User earned a reward
}
})
adUnit?.loadAd()
RewardedAdUnit adUnit = null;
adUnit = new RewardedAdUnit(this, CONFIG_ID);
adUnit.setRewardedAdUnitListener(new RewardedAdUnitListener() {
@Override public void onAdLoaded(RewardedAdUnit rewardedAdUnit) {
// Ad loaded and ready to show
adUnit.show();
}
@Override public void onAdDisplayed(RewardedAdUnit rewardedAdUnit) {
// Ad displayed to user
}
@Override public void onAdFailed(
RewardedAdUnit rewardedAdUnit,
AdException exception
) {
// Ad failed to load
}
@Override public void onAdClicked(RewardedAdUnit rewardedAdUnit) {
// Ad was clicked
}
@Override public void onAdClosed(RewardedAdUnit rewardedAdUnit) {
// Ad was closed by user
}
@Override public void onReward(
RewardedAdUnit rewardedAdUnit,
Reward reward
) {
// User earned a reward
}
});
adUnit.loadAd();