Display interstitial ads

If one of your ad networks has an interstitial ad available, the onAdAvailable(InterstitialActivity) method of your listener is called. You can then start playing the video at any time simply by starting the received intent:

// let's assume 5678 as the request code
startActivityForResult(interstitialActivity, 5678)

For this example we’re assuming that you’re calling the above method from one of your app’s Activity.

At this point you’ve passed control of the UX flow to the SDK, which will notify your Activity when the ad is dismissed, like this:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
	// let's assume that the requestCode for a video engagement is 5678
	if (resultCode == Activity.RESULT_OK && requestCode == 5678) {
		InterstitialAdCloseReason adStatus = (InterstitialAdCloseReason) data.getSerializableExtra(InterstitialActivity.AD_STATUS);
		Log.d(TAG, "Interstitial closed with status - " + adStatus);
		if (adStatus.equals(InterstitialAdCloseReason.ReasonError)) {
			String error = data.getStringExtra(InterstitialActivity.ERROR_MESSAGE);
			Log.d(TAG, "Interstitial closed and error - " + error);

The status of the ad is contained in the Intent received in the onActivityResult with the InterstitialActivity.AD_STATUS key and can have one of the following values:

InterstitialAdCloseReason Description
ReasonUserClickedOnAd The interstitial was closed because the user clicked on the ad.
ReasonUserClosedAd The interstitial was explicitly closed by the user.
ReasonVideoEnded The video interstitial was fully watched without any interaction from the user and closed automatically.
ReasonError An error occurred while displaying the ad. The actual error message cause can be retrieved with the InterstitialActivity.ERROR_MESSAGE key.
ReasonUnknown The interstitial was dismissed for an unknown reason.

Note that the reason why the interstitial was dismissed may not be known, in particular if the underlying mediated SDK does not notify its client of whether an interstitial ad was clicked or just dismissed by the user.

Adding Custom Parameters for Interstitials

If you are interested in adding a custom parameter to your Android SDK Interstitials request, you can pass along custom parameters in this way:

// creating a map of parameters to be used with a specific interstitial requester
Map mapOfParameters = new HashMap<String,String>();
mapOfParameters.put("pub0", "value0");
mapOfParameters.put("pub1", "value1");

InterstitialRequester interstitialRequester = InterstitialRequester.create(callback);

//adding a custom parameter to be used with this interstitial requester
interstitialRequester.addParameter("pub2", "pub2")
//adding a list of custom parameters to be used in this interstitial requester