Card Ad

Declare DisplayAd class

import com.intowow.sdk.DisplayAd;

private final static String PLACEMENT_NAME = "Obtain from your Intowow account manager";
private DisplayAd mDisplayAd = null;

Initialize DisplayAd class

mDisplayAd = new DisplayAd(mActivity);

NOTE : please make sure to pass Activity on to the DisplayAd, if you can't, then you may need to pass it on mDisplayAd.getView(activity); API.

Setup the RequestInfo

  • You need to set the placement ID and the request timeout in requestInfo.

RequestInfo requestInfo = new RequestInfo();
requestInfo.setPlacement(PLACEMENT_NAME);
requestInfo.setTimeout(timeout);

Load ad with RequestInfo

loadAdInstant

import com.intowow.sdk.CERequestResult;

CERequsetResult result = mDisplayAd.loadAdInstant(requestInfo);
 if (result.isSuccess()) {
    View mAdView = mDisplayAd.getView();
    // TODO: Attach the Ad View
 } else {
    // You can call result.getError() to know info of loadAd fail
 }
}

With loadAdInstant , our synchronous method , You will get the result of loading ad by CERequestResult directly.

loadAdAsync

import com.intowow.sdk.CEAdListener;
import com.intowow.sdk.CEAdRequestListener;

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

            @Override
            public void onAdLoaded(Ad ad) {
                if (mDisplayAd != ad) {
                    return;
                }
                //  [NOTE]
                //  After onAdLoaded, you can call mDisplayAd.getView()
                //  to add ad view to the UI hierarchy.
                //  If you do not pass Activity on to the mDisplayAd yet,
                //  please use mDisplayAd.getView(activity) instead of
                //  mDisplayAd.getView()
                View adView = mDisplayAd.getView();
                if (adView != null) {
                    ...
                    ....
                }
            }
});

loadAdAsync is an asynchronous method, you can set timeout via RequestInfo, and get the result of ad request by CEAdRequestListener.

Add CEAdListener to get the ad event callback.

import com.intowow.sdk.Ad;
import com.intowow.sdk.AdError;
import com.intowow.sdk.CEAdListener;
import com.intowow.sdk.DisplayAd;

mDisplayAd.setAdListener(new CEAdListener() {
    @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 onVideoStart(Ad ad) {
    }

    @Override
    public void onVideoProgress(Ad ad, int totoalDuration, int currentPosition) {
    }

    @Override
    public void onVideoEnd(Ad ad) {
    }
});

Release ad

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

If you want to get more information about integration, please refer to DisplayAd class.

Last updated