-
Notifications
You must be signed in to change notification settings - Fork 3
API Reference (EN)
getSdkVersion()
init(Activity activity, String mediaId, MaioAdsListener listener)
setAdTestMode(boolean testMode)
setMaioAdsListener(MaioAdsListener listener)
canShow()
canShow(String zoneId)
show()
show(String zoneId)
onInitialized()
onChangedCanShow(String zoneId, boolean newValue)
onOpenAd(String zoneId)
onStartedAd(String zoneId)
onFinishedAd(int playtime, boolean skipped, int duration, String zoneId)
onClickedAd(String zoneId)
onClosedAd(String zoneId)
onFailed(FailNotificationReason reason, String zoneId)
Get maio SDK version number.
v1.0.2 +
public static String getSdkVersion()
Initialize the SDK.
public static void init(Activity activity, String mediaId, MaioAdsListener listener)
-
activity
Application activity
-
mediaId
The mediaid generated for your application located in the maio dashboard
-
listener
Listener to capture SDK events
MaioAds.init(this, MEDIA_ID, new MaioAdsListener() {
// SDK prepared event
@Override
public void onInitialized() {}
// SDK status change from Can Show video to Cannot Show Video event
@Override
public void onChangedCanShow(String zoneId, boolean newValue) {}
// Video about to play event
@Override
public void onOpenAd(String zoneId) {}
// Video started event
@Override
public void onStartedAd(String zoneId) {}
// Video finished event
@Override
public void onFinishedAd(int playtime, boolean skipped, int duration, String zoneId) {}
// Video Endcard closed event
@Override
public void onClosedAd(String zoneId) {}
// Video Endcard clicked event
@Override
public void onClickedAd(String zoneId) {}
// Error event
@Override
public void onFailed(FailNotificationReason reason, String zoneId) {}
});
Set SDK to test mode.
public static void setAdTestMode(boolean testMode)
-
testMode
To run the SDK in test mode use true, otherwise use false. Set test mode to
true
while developing your app andfalse
once released to Play Store (default value isfalse
).
// Sets SDK to test mode. Comment out when it is time to release your app.
MaioAds.setAdTestMode(true);
// SDK inititialize
MaioAds.init(this, MEDIA_ID, new MaioAdsListener() {
});
Set listener to capture SDK events.
public static void setMaioAdsListener(MaioAdsListener listener)
-
listener
Listener to capture SDK events
Default zone is ready to show a video ad true
is returned, else false
is returned.
※Used when running 1 zone.
public static boolean canShow()
if (MaioAds.canShow()) {
MaioAds.show();
}
Specified zone is ready to show a video ad true
is returned, else false
is returned.
※Used when running multiple zones.
public static boolean canShow(String zoneId)
-
zoneId
ZoneId of the zone you want to display a video ad for.
if(MaioAds.canShow(ZONE_ID1)) {
MaioAds.show(ZONE_ID1);
}
Display video ad for default zone. ※Used when running 1 zone.
public static void show()
if (MaioAds.canShow()) {
MaioAds.show();
}
Display video ad for specified zone. ※Used when running multiple zones.
public static void show(String zoneId)
-
zoneId
ZoneId of the zone you want to display a video ad for.
if(MaioAds.canShow(ZONE_ID1)) {
MaioAds.show(ZONE_ID1);
}
Called when all zones have been prepared
public void onInitialized()
Called when a zones status has changed from Can Show Video to Cannot Show Video
public void onChangedCanShow(String zoneId, boolean newValue)
-
zoneId
Status changed zoneId
-
newValue
Current Status.
true
= Can Show Videofalse
= Cannot Show Video
void onChangedCanShow(String zoneId, boolean newValue) {
if(newValue){
MaioAds.show(zoneId);
}
}
Called when video is about to play. Only called once, not called on replays.
public void onOpenAd(String zoneId)
-
zoneId
ZoneId for ad being played
Called when video starts.
public void onStartedAd(String zoneId)
-
zoneId
ZoneId for ad being played
Called when video finished playing. Only called once, not called on replays.
public void onFinishedAd(int playtime, boolean skipped, int duration, String zoneId)
-
zoneId
ZoneId for ad being played
-
playtime
Amount of seconds video was actually played
-
skipped
If video was skipped
true
elsefalse
-
duration
Actual video length in seconds
public void onFinishedAd(int playtime, boolean skipped, int duration, String zoneId) {
// TODO: code to reward user
}
Called when end card is clicked going to store/website.
public void onClickedAd(String zoneId)
- zoneId
ZoneId for clicked ad
Called when the ad is closed.
public void onClosedAd(String zoneId)
-
zoneId
ZoneId for closed ad
Called when there is an SDK error. SDK error are for debugging purpose only.
public void onFailed(FailNotificationReason reason, String zoneId)
-
zoneId
Zone that caused error
-
reason
Reason for error
maio SDK error types
-
AD_STOCK_OUT
Out of ads
-
RESPONSE
Problem with response from server
-
NETWORK_NOT_READY
No network
-
NETWORK
Network error (timeout, client error etc)
-
UNKNOWN
Unknown error (threading/async tasks, file server errors etc)
-
VIDEO
Video ad error