Home / Android / Interstitials/Full Screen for Static or Video ads / Example

Interstitials/Full Screen for Static or Video ads

Example

public class InterstitialActivity extends Activity {

TappxInterstitial tappxInterstitial;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tappxInterstitial = new TappxInterstitial(InterstitialActivity.this, "**YOUR-APP-KEY**");
tappxInterstitial.setAutoShowWhenReady(true);
tappxInterstitial.loadAd();
}

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

If you want to have more control, you can use the following three options: loadAd, isReady and show.

loadAd is the request to get the ad and load all the information so you can show the ad.

tappxInterstitial.loadAd();`

isReady allows you to check if the ad is ready to be shown. You will receive a “true” if the ad is ready and a “false” if not.

tappxInterstitial.isReady();

show allows you to display the interstitial ad that has loaded previously.

tappxInterstitial.show();

These three options are useful in games, for example, if you want to load the ad while the user is playing and show it immediately after the user finishes to play.