Page tree


Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Anchor
top
top
Table of Contents
indent20px
stylenone

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 PMInterstitialAd object 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 PMInterstitialAd:

Code Block
languagejava
themeConfluence
titleCreate PMInterstitialAd Instance
linenumberstrue
PMInterstitialAd interstitialAd = new PMInterstitialAd(<Context>);
interstitialAd.setUseInternalBrowser(true);//Optional‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


Warning

Be sure to pass the Activity context when creating an instance of PMInterstitialAd.


Step 2: Create Ad Request

Create an instance of PMInterstitialAdRequest and set the targeting parameters:

Code Block
languagejava
themeConfluence
titleRequest The adRequest With loadAdRequest()
linenumberstrue
PMInterstitialAdRequest adRequest = PMInterstitialAdRequest.createPMInterstitialAdRequest(
        <PubId>, <SiteId>, <AdId>);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


Info
For more targeting parameters, see Passing Targeting Information.


Step 3: Request the ad

Send the adRequest using loadRequest() from the interstitialAd instance:

Code Block
languagejava
themeConfluence
titleRequest the Ad With loadRequest
linenumberstrue
interstitialAd.loadRequest(adRequest);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


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:

Code Block
languagejava
themeConfluence
titleReceive Intersitial Callbacks
linenumberstrue
collapsetrue
interstitialAd.setRequestListener(new PMInterstitialAd.InterstitialAdListener.RequestListener() {
    @Override
    public void onFailedToReceiveAd(PMInterstitialAd adView, final PMError error) {
    }
    @Override
    public void onReceivedAd(PMInterstitialAd adView) {
        if(mInterstitialAd.isReady()) {
            mInterstitialAd.show();
        }
    }
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


Info
See PubMatic SDK Error Codes for a detailed description of the PMError object used in the interstitialAd.onFailedToReceiveAd() callback.


Best Practices:

  • Before displaying the Interstitial ad, make sure it's ready using the isReady() method from the PMInterstitialAd object, as shown in step 4 above.
  • Use show() or showForDuration() method from the PMInterstitialAd object to display a full-screen Interstitial ad. The ad displays only after it successfully loads.
  • Call the show() or showForDuration() method from 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 PMInterstitialAd instance.


Step 5: Deallocate the Interstitial ad resources

Deallocate the PMInterstitialAd instance before your Activity is destroyed:

Code Block
languagejava
themeConfluence
titleDeallocate The Ad Resources
linenumberstrue
interstitialAd.destroy();‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


Set Optional Listeners

PubMatic SDK also provides optional listeners that you can register for other callbacks as shown below:

Info
Implement respective listeners in place of any place holders.


Code Block
languagejava
themeConfluence
titleOptional Listeners
linenumberstrue
collapsetrue
// Invoked when the ad will navigate to a clicked link (or rich media open). 
interstitialAd.setActivityListener(<InterstitialAdListener.ActivityListener>);
// Set an interface to notify the events of MRAID ads
interstitialAd.setRichMediaListener(<InterstitialAdListener.RichMediaListener>);
// Set an interface allowing you to control which device features are exposed to rich media ads
interstitialAd.setFeatureSupportHandler(<InterstitialAdListener.FeatureSupportHandler>);
// Set an interface to notify the activity of internal browser.
interstitialAd.setInternalBrowserListener(<InterstitialAdListener.InternalBrowserListener>);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


Info

To fully support all MRAID events please follow the steps in Rich Media (MRAID 2.0) Ads.


⇧ Top