Interstitial ads are full-screen ads displayed at transition points in an app; for example, when the app launches, when moving between screens, and so on. Interstitial ads exhibit the following behavior:
- Always includes a Close button; either immediately, or shortly after, the ad displays.
- One-time ad; once the ad closes the same
PMInterstitialAdobject cannot display it again.
You'll need to follow the instructions in Getting started before proceeding with the following integration steps. You'll also find a useful example integration in pubmatic-sample-app included in the SDK download bundle.
Once you've downloaded and installed the PubMatic Android SDK, use the following sections to implement and configure Interstitial ads:
Display Interstitial Ad
The following steps demonstrate how to integrate Interstitial ads with your app:
Step 1: Setup Interstitial ad
Create an instance of
Be sure to pass the
Activity context when creating an instance of
Step 2: Create Ad Request
Create an instance of
PMInterstitialAdRequest and set the targeting parameters:
Step 3: Request the ad
loadRequest() from the
Step 4: Receive Interstitial callbacks and present the Interstitial ad
Optionally, you can register a listener to report success and failure callbacks from the ad request:
PMErrorobject used in the
- Before displaying the Interstitial ad, make sure it's ready using the
isReady()method from the
PMInterstitialAdobject, as shown in step 4 above.
showForDuration()method from the
PMInterstitialAdobject to display a full-screen Interstitial ad. The ad displays only after it successfully loads.
- Call the
onReceivedAd()callback to display the ad faster. This also ensures that a full-screen Interstitial ad view displays only after the ad is successfully received from the server.
- Remember that Interstitial ads are a one-time ads that display only once. To request another ad, call
loadRequest()again or create a new
Step 5: Deallocate the Interstitial ad resources
PMInterstitialAd instance before your
Activity is destroyed:
Set Optional Listeners
PubMatic SDK also provides optional listeners that you can register for other callbacks as shown below:
To fully support all MRAID events please follow the steps in Rich Media (MRAID 2.0) Ads.