SDK Interface Description
2.1 Get SDK manager instance
ULUAdsSDKManage.getInstance();
2.2 Initialize (required)
You need to initialize by calling the init method at the beginning of the program. In the state of initialization failure, the game should not continue to call the rest of the SDK APIs, and this method must be called in the UI thread. After the game is started, unless initialization failure or abnormality, multiple calls to the initialization interface are not allowed.
2.2.1 Method signature
void init(Activity activity, String gameId, ULURewardedAdCallback uluRewardedAdCallback)
parameters | explanation |
---|---|
activity | Game activity, can not be null |
gameId | The game id in the parameter table |
ULURewardedAdCallbackWithRewardInfo | callback |
2.2.2 Code sample
String gameId="1";
ULUAdsSDKManage.getInstance().init(MainActivity.this, gameId, new ULURewardedAdCallbackWithRewardInfo() {
@Override
public void onAdInitSuccess() {
}
@Override
public void onAdInitFailed(String errMsg) {
//TODO try init again
}
@Override
public void onRewardedAdLoaded() {
//It is recommended that the game set the ad button to be unavailable before the ad is loaded.
}
@Override
public void onRewardedAdFailedToLoad(String error) {
}
@Override
public void onRewardedAdOpened() {
}
@Override
public void onRewardedAdClosed() {
//User close the ad, sdk will load ad automatically
//It is recommended that the game set the ad button to be unavailable before the ad is loaded.
}
@Override
public void onUserEarnedReward(String type, String amount, Object extra) {
//The user receives an ad reward callback. Please process the user reward logic in this callback.
//In general extra is an additional parameter. It is only used when the first two parameters cannot meet the requirements. Extra is generally not processed.
}
@Override
public void onRewardedAdFailedToShow(String error) {
}
@Override
public void onRewardedVideoAdPlayEnd() {
}
@Override
public void onRewardedVideoAdPlayClicked() {
}
});
2.3 Load ad (required)
Please make sure to call this interface after initialization is successful and it must be called in the UI thread.
2.3.1 Method signature
void loadRewardedAd(String placement)
parameters | explanation |
---|---|
placement | The id start with game id in the parameter table |
2.3.2 Code sample
ULUAdsSDKManage.getInstance().loadRewardedAd(uluAdId);
2.4 Show ad (required)
Please be sure to call this interface after the ad is loaded, and it must be called in the UI thread.
2.4.1 Method signature
void showRewardedVideo()
2.4.2 Code sample
ULUAdsSDKManage.getInstance().showRewardedVideo();
```