I2WAPI
package com.intowow.sdk
public class I2WAPI
This class is SDK main program class.
Initialize SDK
You should add
I2WAPI.init()
,I2WAPI.onActivityResume()
andI2WAPI.onActivityPause()
to all of the activities. In order to let the integration more simplified, we recommend you to add these API to your Application class:
public class BaseApplication extends Application {
private static final boolean IS_SUPPORT_LIFECYCLE_CALLBACKS =
(Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH);
private static BaseApplication mInstance = null;
@Override
public void onCreate() {
super.onCreate();
mInstance = this;
if(IS_SUPPORT_LIFECYCLE_CALLBACKS) {
mInstance.registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
// TODO
// Initilize intowow sdk
//
boolean isTestMode = is use test ad or not.
boolean isOpenVerboseLog = is open verbose log or not.
I2WAPI.init(activity.getApplicationContext(), isTestMode, isOpenVerboseLog);
}
@Override
public void onActivityStarted(Activity activity) {
}
@Override
public void onActivityResumed(Activity activity) {
// TODO
// Notify sdk that Activity has already in resume status
//
I2WAPI.onActivityResume(activity.getApplicationContext());
}
@Override
public void onActivityPaused(Activity activity) {
// TODO
// Notify sdk that Activity has already in pause status
//
I2WAPI.onActivityPause(activity.getApplicationContext());
}
@Override
public void onActivityStopped(Activity activity) {
}
@Override
public void onActivitySaveInstanceState(Activity activity,
Bundle outState) {
}
@Override
public void onActivityDestroyed(Activity activity) {
}
});
}
}
}
If you initialize SDK by
init(Context context, boolean isTestAd)
orinit(Context context, boolean isTestAd, boolean isVerbose)
, be sure to configure the isTestAd and isVerbose tofalse
before you release the build to the production environment.
Public methods
void
JSONObject
getAdditionalInfo(Context context) Get SDK additional info. such as device id, SDK version etc.
List<Long[]>
getAdsValidTime(Context context, String placement)
Return the ad valid time slot array by placement.
void
init(Context context) Initialize sdk.
void
init(Context context, boolean isTestAd) Initialize sdk.
void
init(Context context, boolean isTestAd, boolean isVerbose) Initialize sdk.
void
onActivityResume(Context context) Notify sdk that Activity has already in resume status.
void
onActivityPause(Context context) Notify sdk that Activity has already in pause status.
void
preload(Context context, String placement) Notify the SDK to preload this placement.
void
preload(Context context, RequestInfo requestInfo) Notify the SDK to preload this placement by RequestInfo.
boolean
hasReadyAd(Context context, String placement) Return true if there is at least one ready ad, otherwise return false.
void
setAdUrlLoadingListener(Context context, AdUrlLoadingListener listener) Handle ad engage event. SDK will call listener.shouldOverrideUrlLoading() for App while user engage and you can decide to open device's default browser or do other thing you want.
void
setAudienceTargetingTags(Context context, List tagList) Set audience tags for targeting.
void
setDownloadTrafficListener(Context context, DownloadTrafficListener listener) To report the download size to App.
void
setMaximumBitmapCacheSize(Context context, int maximumBitmapCacheSize) Set the maximum bitmap size for cache.
Public methods
blockAd
void blockAd(Context context, Ad ad, int reason, String description)
Block an ad.
Parameters
context
Context: the context.
ad
Ad: the ad you want to block.
reason
int: the reason code. 1 : not relevant, 2 : see the same ad too often, 3 : inappropriate
description
String: the description.
getAdditionalInfo
JSONObject getAdditionalInfo(Context context)
Get SDK additional info. such as device id, SDK version etc.
Parameters
context
Context: the context.
Returns
JSONObject
SDK additional info.
void init(Context context)
getAdsValidTime
List<Long[]> getAdsValidTime(Context context, String placement)
Get the ads valid time slot interval. Example: [[startTime, endTime], [startTime, endTime] ....]
Parameters
context
Context: the context.
placement
String: the placement.
Returns
List<Long[]>
return the valid ads time array.
init
Initialize sdk.
Parameters
context
Context: the context.
init
void init(Context context, boolean isTestAd)
Initialize sdk.
Parameters
context
Context: the context.
isTestAd
boolean: if SDK needs to fetch test ad for testing purpose or not. APP should set this flag to "false" before deploying to the production environment.
init
void init(Context context, boolean isTestAd, boolean isVerbose)
Initialize sdk.
Parameters
context
Context: the context.
isTestAd
boolean: if SDK needs to fetch test ad for testing purpose or not. APP should set this flag to "false" before deploying to the production environment.
isVerbose
boolean: is print verbose log or not. APP should set this flag to "false" before deploying to the production environment.
onActivityResume
void onActivityResume(Context context)
Notify sdk that Activity has already in resume status.
Parameters
context
Context: the context.
onActivityPause
void onActivityPause(Context context)
Notify sdk that Activity has already in pause status.
Parameters
context
Context: the context.
preload
void preload(Context context, String placement)
Notify the SDK to preload this placement.
Parameters
context
Context: the context.
placement
String: the placement you want to preload.
preload
void preload(Context context, RequestInfo requestInfo)
Notify the SDK to preload by RequestInfo
hasReadyAd
boolean hasReadyAd(Context context, String placement)
Check is there any ready ad at this moment
Parameters
context
Context: the context.
placement
String: the placement you want to check.
Returns
boolean
return true if there is at least one ready ad, otherwise false
setAdUrlLoadingListener
void setAdUrlLoadingListener(Context context, AdUrlLoadingListener listener)
Handle ad engage event. SDK will call listener.shouldOverrideUrlLoading() for App while user engage and you can decide to open device's default browser or do other thing you want.
Parameters
context
Context: the context.
listener
AdUrlLoadingListener: the listener will be saved as WeakReference in the SDK, so App should maintain this listener by self.
setAudienceTargetingTags
void setAudienceTargetingTags(Context context, List<String> tagList)
Set audience tags for targeting.
Parameters
context
Context: the context.
tagList
List<String>: all tags for targeting.
setDownloadTrafficListener
void setDownloadTrafficListener(Context context, DownloadTrafficListener listener)
To report the download size to App.
Parameters
context
Context: the context.
listener
DownloadTrafficListener: the listener will be saved as WeakReference in the SDK, so App should maintain this listener by self.
setMaximumBitmapCacheSize
void setMaximumBitmapCacheSize(Context context, int maximumBitmapCacheSize)
Set the maximum bitmap size for cache.
Parameters
context
Context: the context.
maximumBitmapCacheSize
int: the maximum bitmap size for cache.
Last updated