Interstitial Ads | Android

To Start, you first need to declare an Interstitial variable using the following method:

Interstitial interstitial;

Then in your onCreate or in your onResume add the following lines:

interstitial = new Interstitial(this); //'this' is your Context
interstitial.setInterstitialAdListener(interstitialAdListener);
interstitial.getAdSettings().setPublisherId(your_publisher_id);
interstitial.getAdSettings().setAdspaceId(your_adspace_d);

The InterstitialAdListener will support the following methods:

interstitial.setInterstitialAdListener(new InterstitialAdListener() {
    @Override
    public void onReadyToShow() {
        // interstitial is loaded an may be shown
    }

    @Override
    public void onWillShow() {
        // called immediately before the interstitial is shown
    }

    @Override
    public void onWillOpenLandingPage() {
        // called immediately before the landing page is opened, after the user clicked
    }

    @Override
    public void onWillClose() {
        // called immediately before the interstitial is dismissed
    }

    @Override
    public void onFailedToLoadAd() {
        // loading the interstitial has failed
    }
});

In order to load a new banner, please use the following:

interstitial.asyncLoadNewBanner();

As soon as an Interstitial has been loaded, the InterstitialAdListener onReadyToShow() method will be called.

If not, the onFailedToLoadAd() will be called.

When an Interstitial was successfully loaded you then need to call show() method using the following:

interstitial.show();

Interstitial Orientation Modes

Here you will find the details for orienting your Android Interstitial Adspaces for devices using your application. There are currently three orientation modes that can be used; Landscape, Portrait, or Split-Screen.

Landscape Mode

Use the following block of code:

<!-- Smaato Activities. --> 
  
<activity android:name="com.smaato.soma.interstitial.InterstitialActivity" android:resizeableActivity="false" android:screenOrientation="landscape" />
<activity android:name="com.smaato.soma.video.VASTAdActivity" android:resizeableActivity="false" android:screenOrientation="landscape" /> 

<activity android:name=”com.smaato.soma.ExpandedBannerActivity” android:resizeableActivity=”false” android:screenOrientation=”landscape” />

Portrait Mode

For portrait mode, use the following block of code:

<!-- Smaato Activities. --> 
  
<activity android:name="com.smaato.soma.interstitial.InterstitialActivity" android:resizeableActivity="false" android:screenOrientation="portrait" />
<activity android:name="com.smaato.soma.video.VASTAdActivity" android:resizeableActivity="false" android:screenOrientation="portrait" /> 

<activity android:name=”com.smaato.soma.ExpandedBannerActivity” android:resizeableActivity=”false” android:screenOrientation=”portrait” />

Split Screen Mode (Android Nougat)

Starting with the release of Android Nougat, publishers can use the split-screen/multi-window mode in their apps. If you intend to use this, you’ll need to add the statement for Smaato activities in your AndroidManifest.xml file. See the following example:

<!-- Smaato Activities. -->
 
<activity android:name="com.smaato.soma.interstitial.InterstitialActivity" android:resizeableActivity="false" android:configChanges="keyboardHidden|orientation|screenSize" />
<activity android:name="com.smaato.soma.video.VASTAdActivity" android:resizeableActivity="false" android:configChanges="keyboardHidden|orientation|screenSize" />
<activity android:name="com.smaato.soma.ExpandedBannerActivity" android:resizeableActivity="false"android:configChanges="keyboardHidden|orientation|screenSize" />

Destroying the Interstitial Ad

When you finish using the interstitial ad unit and want to clean up memory usage, please call the destroy() method as per the following:

@Override
public void onDestroy() {
   interstitial.destroy();
   super.onDestroy();
}

Interstitial (Multi-Ad-Format) NEW

Interstitial (Multi-Ad Format) works by requesting ads for both interstitial video ads and standard interstitial (image/rich media) Ads. In the end, the highest bid will win the auction and can deliver the ad which is for either interstitial video or interstitial image/rich media.

  1. Smaato needs to activate the Multi-Ad Format feature for you as a publisher. 
  2. Log in to your SPX account and create a new Multi-Ad Format interstitial ad space.
  3. Download and import the latest version of our Android and iOS SDK from SPX, which also includes new adapter classes.

Integrating Multi-Ad-Format

Integrate a new optimized ad view class – MultiFormatInterstitial.

  • If you want to enable multi-format interstitial ads for an existing implementation of interstitial, it is sufficient to change the class name to MultiFormatInterstitial
  • If you want to enable multi-format interstitial ads for an existing implementation of video, you need to change the class name to MultiFormatInterstitial and also to use InterstitialAdListener instead of VastAdListener (change setVastAdListener() to setInterstitialAdListener())

Example Code

MultiFormatInterstitial multiFormatInterstitial = new MultiFormatInterstitial(getContext());
multiFormatInterstitial.setInterstitialAdListener(new InterstitialAdListener() {
@Override
 public void onReadyToShow() {
 
    }
 
@Override
 public void onWillShow() {
 
    }
 
@Override
 public void onWillOpenLandingPage() {
 
    }
 
@Override
 public void onWillClose() {
 
    }
 
@Override
 public void onFailedToLoadAd() {
 
    }
});

Update Mediation Adapter Classes

AdMob as primary

  • Integrate MultiFormatInterstitialAdMobMediationAdapter mediation adapter into your project.
  • Next, follow the instructions on how to integrate Interstitial Ads with AdMob as primary and Smaato as secondary, but please make sure that MultiFormatInterstitialAdMobMediationAdapter is inserted with the appropriate “Class Name” for example: {{com.smaato.soma.MediationAdapter.MultiFormatInterstitialAdMobMediationAdapter}}

MoPub as primary

  • Integrate SomaMopubMultiFormatInterstitialAdapter mediation adapter into your project.
  • Next, follow the instructions on how to integrate interstitial ads with MoPub as primary and Smaato as secondary, but please also make sure that SomaMopubMultiFormatInterstitialAdapter is inserted with the appropriate “Custom Event Class” for example: {{com.smaato.soma.mopubcustomevent.SomaMopubMultiFormatInterstitialAdapter}}

Cleaning up the MultiFormatInterstitial Ad

After you finish using the MultiFormatInterstitial, it’s highly recommended to clean up the memory by calling the destroy() method as per the following Destructor code example:

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

Modified: July 18, 2019 at 2:56 pm