InterstitialAd

package com.intowow.sdk

public class InterstitialAd extends Ad

Characteristics

  • Takes up the whole screen. Users could engage with the ad or close the ad and back to app.

  • Support portrait and landscape mode.

  • Support image and video.

  • Video is mute by default, and can be toggled by clicking it.

Request an ad

  • Declare InterstitialAdActivity to AndroidManifest.xml

<activity
  android:name="com.intowow.sdk.InterstitialAdActivity"
  android:configChanges="orientation|screenSize"
  android:launchMode="singleTask"
  android:screenOrientation="portrait"
  android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" >
</activity>
  • You could request an ad by:

private InterstitialAd mInterstitialAd = null;
private final static String PLACEMENT_NAME = "Obtain from your Intowow account manager";

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  mInterstitialAd = new InterstitialAd(mActivity);
  RequestInfo requestInfo = new RequestInfo();
  requestInfo.setPlacement(PLACEMENT_NAME);
  requestInfo.setTimeout(LOAD_AD_TIMEOUT);

  mInterstitialAd.setAdListener(new CEInterstitialAdListener() {

    @Override
    public void onAdDisplayed(Ad ad) {
    }

    @Override
    public void onAdDismissed(Ad ad) {
    }

    @Override
    public void onAdClicked(Ad ad) {
    }

    @Override
    public void onAdImpression(Ad ad) {
    }

    @Override
    public void onAdMute(Ad ad) {
    }

    @Override
    public void onAdUnmute(Ad ad) {
    }

    @Override
    public void onVideoEnd(Ad arg0) {
    }

    @Override
    public void onVideoProgress(Ad arg0, int totalDuration, int currentPosition) {
    }

    @Override
    public void onVideoStart(Ad arg0) {
    }

  });

  mInterstitialAd.loadAdAsync(requestInfo, new CEAdRequestListener() {
    @Override
    public void onError(Ad ad, AdError error) {
    }

    @Override
    public void onAdLoaded(Ad ad) {
        if(mInterstitialAd != ad) {
            return;
        }
        //  Start InterstitialAdActivity for showing this ad.
        //
    mInterstitialAd.show();      
    }
  });
}
  • remember to release ad if it is no longer to use.

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

Advance Integration

Public constructors

InterstitialAd(Context context) Instantiates a new interstitial ad.

InterstitialAd(Context context, Map adProps) Instantiates a new interstitial ad.

Public methods

void

close() Close the InterstitialActivity directly.

void

destroy() Release the interstitial ad.

loadAdInstant(RequestInfo requestInfo) Load ad with requestInfo (synchronous)

void

setAutoCloseWhenEngaged(boolean isAutoClose) Instruct SDK to close the interstitial ad after user clicks the ad. You should call this method before loadAdInstant/loadAdAsync if necessary.

void

show() Start the InterstitialActivity. You should call this method after onAdLoaded().

void

show(int enterAnim, int exitAnim) Start the InterstitialActivity with animation effect. You should call this method after onAdLoaded().

Inherited methods

int

getAdId() Get the ad id.

String

getCampaignId() Get the campaign id.

String

getEngageUrl() Get the engage url.

int

getPlace() Get the ad place.

String

getPlacement() Get the ad placement.

Rect

getSize() Get the ad size. It should be called after onAdLoaded().

String

getToken() Get the ad token for tracking.

long

getTotalFileSize() Get the ad file size on device.

String

getVideoCoverPath() Get video cover file path. It should be called after onAdLoaded().

boolean

hasVideoContent() Check if the ad has video content or not.

boolean

isValid() Check if the ad is still valid for serving.

void

setSize(Rect rect) Set the ad size.

Public constructors

InterstitialAd

InterstitialAd(Context context)

Instantiates a new interstitial ad.

Parameters

context

Context: the context.

Public methods

close

void close()

Close the InterstitialActivity directly.

destroy

void destroy()

Release the ad.

loadAdInstant

CERequestResult loadAdInstant(RequestInfo requestInfo)

Load ad with RequestInfo (synchronous)

Parameters

requestInfo

RequestInfo: the request info such as placement and timeout.

loadAdAsync

void loadAdAsync(RequestInfo requestInfo, CEAdRequestListener listener)

Load ad with RequestInfo (asynchronous)

Parameters

requestInfo

RequestInfo: the request info such as placement and timeout.

listener

CEAdRequestListener: know the result of loadAdAsync

setAdListener

void setAdListener(CEInterstitialAdListener listener)

Set the ad listener.

Parameters

listener

CEInterstitialAdListener: the ad listener.

setAutoCloseWhenEngaged

void setAutoCloseWhenEngaged(boolean isAutoClose)

Instruct SDK to close the interstitial ad after user clicks the ad. You should call this method before loadAdInstant/loadAdAsync if necessary.

Parameters

isAutoClose

boolean: if auto close when ad is engaged or not.

show

void show()

Start the InterstitialActivity. You should call this method after onAdLoaded().

show

void show(int enterAnim, int exitAnim)

Start the InterstitialActivity with animation effect. You should call this method after onAdLoaded().

Parameters

enterAnim

int: A resource ID of the animation resource to use for the incoming activity. Use 0 for no animation.

exitAnim

int: A resource ID of the animation resource to use for the outgoing activity. Use 0 for no animation.

Last updated