Skip to main content
Version: 6.x.x

Interstitial Ads

Overview

Before You Start. Make sure that you have correctly integrated the BlueStack SDK into your application. Integration is outlined here.

For a working implementation of this ad format, see the azerion-inapp-demo-android demo app.

Create an Interstitial Ad

To create an interstitial you must init an object with type InterstitialAd :

InterstitialAd interstitialAd = new InterstitialAd(activity, "INTERSTITIAL_PLACEMENT_ID");

Load an Interstitial Ad

Note: Make all calls to the BlueStack SDK on the main thread.

With RequestOptions

To request an interstitial ad using RequestOptions, provide an instance of RequestOptions in the InterstitialAd's load method:

interstitialAd.load(requestOptions);

Without RequestOptions

interstitialAd.load()

Note:

  • To avoid stacking up two interstitial Ad BlueStack added lock system :

    • InterstitialAd will ignore any interstitial request while there is a pending request or there is interstitial shown at that moment.

Ad events

Register for Interstitial events

To recieve ad's lifecycle events regisger a listerner in InterstitialAd.

// set intertitial listener
public class InterstitialFragment extends Fragment implements InterstitialAdListener {
...
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
interstitialAd.setInterstitialAdListener(this);
...
}
...
}

Implement Interstitial events

The SDK will notify your Listener of all possible events listed below :

  • onAdLoaded(): will be called by the SDK when your Interstitial is ready.
@Override
public void onAdLoaded() {
Log.d(TAG, "interstitial did load");
}
  • onAdFailedToLoad(Exception adsException): will be called when all ads servers fail. it will return the error of last called ads server.
@Override
public void onAdFailedToLoad(Exception adsException) {
Log.e(TAG, "interstitial did fail :" + adsException.toString());
}
  • onAdDisplayed(): will be called when interstitial was shown.
@Override
public void onAdDisplayed() {
Log.d(TAG, "interstitial Did Shown");
}
  • onAdFailedToDisplay(@NonNull Exception exception): will be called when interstitial is failed to display.
@Override
public void onAdFailedToDisplay(@NonNull Exception exception) {
Log.e(TAG, "interstitial did fail :" + adsException.toString());
}
  • onAdClicked(): will be called when user click the Interstitial ad.
@Override
public void onAdClicked() {
Log.d(TAG, "Ad Clicked");
}
  • onAdDismissed(): will be called when interstitial was dismissed.
@Override
public void onAdDismissed() {
Log.d(TAG, "interstitial disappear");
}

Show an Interstitial Ad

To check if the interstitial is ready to be shown, you must call isReady() and show() in order to display the ad (in case of success) :

...
if (interstitialAd.isReady()) {
interstitialAd.show();
} else {
Log.d(TAG, "Interstitial not ready ");
}
...

Destroying Interstitial Ad

When you have finished your ads plant you must free the memory.

@Override
protected void onDestroy() {
if (interstitialAd != null) {
interstitialAd.destroy();
interstitialAd = null;
}
super.onDestroy();
}