DispayAd
package com.intowow.sdk
public class DisplayAd extends Ad

Characteristics
Support image and video.
Video is mute by default, and can be toggled by clicking it.
Recommended Ad Placement
Custom
Request an ad
You could request an ad by:
private final static String PLACEMENT_NAME = "Obtain from your Intowow account manager";
private final static long LOAD_AD_TIMEOUT = 30000L;
private DisplayAd mDisplayAd = new DisplayAd(mActivity);
RequestInfo requestInfo = new RequestInfo();
requestInfo.setPlacement(PLACEMENT_NAME);
requestInfo.setTimeout(LOAD_AD_TIMEOUT);
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) {
}
});
mDisplayAd.loadAdAsync(requestInfo, new CEAdRequestListener() {
@Override
public void onError(Ad ad, AdError error) {
adErrorProcess(error);
}
@Override
public void onAdLoaded(Ad ad) {
if (ad != mDisplayAd) {
return;
}
adLoadedProcess();
}
});
remember to release ad if it is no longer to use.
@Override
protected void onDestroy() {
if(mDisplayAd != null) {
mDisplayAd.destroy();
mDisplayAd = null;
}
...
...
super.onDestroy();
}
Advance Integration
You could use
AdProperty
to configure your ad if necessary:
Map<String, Object> adProps = new HashMap<String, Object>();
adProps.put(AdProperty.VIDEO_AUTO_REPEAT, trueOrFalse);
adProps.put(AdProperty.HIDE_AD_ICON, trueOrFalse);
adProps.put(AdProperty.SILENT_START, trueOrFalse);
DisplayAd mDisplayAd = new DisplayAd(context, adProps);
AdProperty.VIDEO_AUTO_REPEAT
: if video auto repeat or not, the default value is true.AdProperty.HIDE_AD_ICON
: if need to hide the ad icon, the default value is false.AdProperty.SILENT_START
: auto silent play, the default value is true.You could use setWidth(int width) to instruct SDK to set an expected width of the ad, and SDK will rescale the ad automatically and keeps the aspect ratio.
You could use hasVideoContent() to check if the ad is video or not after ad loaded.
If you want to resize the ad, please use resize(int width).
NOTE
Please make sure to new an instance before requesting the ad. Do not keep the returned ad too long, otherwise you may display the out-of-dated ad.
Public constructors
DisplayAd(Context context) Instantiates a new display ad.
DisplayAd(Context context, Map adProps) Instantiates a new display ad.
Public methods
void
destroy() Release the display ad.
View
getView() Get the ad view. You should call this method after ad loaded.
View
getView(Activity activity) Get the ad view. You should call this method after ad loaded.
boolean
isAvailableAttachToWindow() Checks if this ad is available to attach to window or not.
boolean
isMute() Checks if this ad is on mute status or not.
loadAdInstant(RequestInfo requestInfo) Load ad with requestInfo (synchronous)
void
loadAdAsync(RequestInfo requestInfo, CEAdRequestListener listener)
Load ad with requestInfo (asynchronous)
void
mute() Mute video ad.
void
play() Allow the ad to play.
boolean
resize(int width) Resize the ad.
boolean
resize(CEAdSize ceAdSize) Resize the ad by CEAdSize.
void
setAdListener(CEAdListener listener) Set the ad listener.
void
setIsVideoAutoRepeat(boolean isVideoAutoRepeat) set if the video ad should auto repeat or not. You should call this method before loadAdInstant/loadAdAsync if necessary.
void
setPlace(int place) Set the ad place.
void
setWidth(int width) Set the ad width. You should call this method before loadAdInstant/loadAdAsync if necessary.
void
stop() Disallow the ad to play.
void
unmute() Unmute video ad.
void
setAdSize(CEAdSize ceAdSize) Set the ad view size by ad ratio. You should call this method before loadAdInstant/loadAdAsync if necessary.
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
DisplayAd
DisplayAd(Context context)
Instantiates a new display ad.
Parameters
context
Context: the context.
DisplayAd
DisplayAd(Context context, String placement, Map<String, Object> adProps)
Instantiates a new display ad.
Parameters
context
Context: the context.
adProps
Map<String, Object>: the ad property.
Public methods
destroy
void destroy()
Release the ad.
getView
View getView()
Gets the ad view. You should call this method after onAdloaded().
Returns
View
the ad view.
getView
View getView(Activity activity)
Gets the ad view. You should call this method after onAdloaded().
Parameters
activity
Activity: For Moat SDK tracking purpose. If you initiate the display ad without using activity and need to use Moat SDK, please use this API to initiate Moat SDK correctly.
Returns
View
the ad view.
isAvailableAttachToWindow
boolean isAvailableAttachToWindow()
Checks if this ad is available to attach to window or not.
Returns
boolean
true the ad is available to attach the window otherwise return false.
isMute
boolean isMute()
Checks if this ad is on mute status or not.
Returns
boolean
true if this ad is on mute status otherwise return false.
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
mute
void mute()
Mute video ad.
play
void play()
Allow the ad to play.
resize
boolean resize(int width)
Resize the ad.
Parameters
width
int: the ad width.
Returns
boolean
true resize the ad successfully otherwise return false.
resize
boolean resize(CEAdSize ceAdSize)
Resize the ad by CEAdSize.
Parameters
ceAdSize
CEAdSize: the CEAdSize.
Returns
boolean
true resize the ad successfully otherwise return false.
setAdListener
void setAdListener(CEAdListener listener)
Set the ad listener.
Parameters
listener
CEAdListener: the ad listener.
setIsVideoAutoRepeat
void setIsVideoAutoRepeat(boolean isVideoAutoRepeat)
Set if the video ad should auto repeat or not. You should call this method before loadAd if necessary.
Parameters
isVideoAutoRepeat
boolean: true the video ad should auto repeat otherwise false.
setPlace
void setPlace(int place)
Set the ad place.
Parameters
place
int: the ad place.
stop
void stop()
Disallow the ad to play.
unmute
void unmute()
Unmute video ad.
setAdSize
void setAdSize(CEAdSize ceAdSize)
Set the ad view size by ad ratio. You should call this method before loadAd if necessary.
Parameters
ceAdSize
CEAdSize: the CEAdSize
Last updated