Interstitial ads are full-screen ads that cover the interface of their host app. They are 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. The RTB-Stack SDK supports both HTML and VAST video content for these ads.
Setting up an interstitial ad involves four main steps:
InterstitialAdView
.Below is a basic example of how to load and display an interstitial ad. In this example, we instantiate the InterstitialAdView and load an ad in the onCreate() method of an Activity. The ad is displayed when it is loaded and ready:
private InterstitialAdView adView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SDKSettings.setRequestBaseUrl("Your endpoint request url");
adView = new InterstitialAdView(this);
adView.setTagID("Your custom tag id");
adView.setAdListener(new AdListener() {
@Override
public void onAdLoaded(AdView adView) {
InterstitialAdView interstitialAdView = (InterstitialAdView) adView;
if(interstitialAdView.isReady()) {
interstitialAdView.show();
}
}
@Override
public void onAdLoaded(NativeAdResponse nativeAdResponse) {
}
@Override
public void onAdRequestFailed(AdView adView, ResultCode resultCode) {
}
@Override
public void onAdExpanded(AdView adView) {
}
@Override
public void onAdCollapsed(AdView adView) {
}
@Override
public void onAdClicked(AdView adView) {
}
@Override
public void onAdClicked(AdView adView, String s) {
}
});
adView.loadAd();
}
@Override
protected void onDestroy() {
super.onDestroy();
if(adView != null) {
adView.activityOnDestroy();
}
}
Note:
The InterstitialAdView allows for configuring various options related to how an ad’s URL is handled:
adView.setClickThroughAction(ANClickThroughAction.OPEN_SDK_BROWSER);
adView.setClickThroughAction(ANClickThroughAction.OPEN_DEVICE_BROWSER);
AdListener.onAdClicked()
callback:adView.setClickThroughAction(ANClickThroughAction.RETURN_URL);