SDK Interface Description
2.1 Get SDK manager instance
2.1.1 Code sample
ULUManager.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 clentId, ULUListener uluListener )
parameters |
explanation |
activity |
Game activity, can not be null |
clentId |
The game id in the parameter table |
uluListener |
callback of methods,such as initialize and login |
2.3 Activity lifecycle callbacks(required)
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ULUManager.getInstance().activityOnCreate(this);
}
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(newBase);
ULUManager.getInstance().ULUAttachBaseContext(newBase);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
ULUManager.getInstance().ULUOnActivityResult(requestCode, resultCode, data);
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
ULUManager.getInstance().ULUOnRequestPermissionsResult(requestCode,permissions,grantResults);
}
@Override
protected void onStart() {
super.onStart();
ULUManager.getInstance().ULUOnStart(this);
}
@Override
protected void onStop() {
super.onStop();
ULUManager.getInstance().ULUOnStop(this);
}
@Override
protected void onPause() {
super.onPause();
ULUManager.getInstance().ULUOnPause(this);
}
@Override
protected void onResume() {
super.onResume();
ULUManager.getInstance().ULUOnResume(this);
}
@Override
protected void onDestroy() {
super.onDestroy();
ULUManager.getInstance().activityOnDestroy(this);
}
2.4 Login (required)
2.4.1 Method signature
void login()
2.4.2 Code sample
ULUManager.getInstance().login();
2.5 Logout (optional)
In general, please log out through the user center below. This method is only used when required for special purposes.
2.5.1 Method signature
void logout(ULUListener uluListener)
parameters |
explanation |
uluListener |
please pass the same listener on init |
2.6 Pay (required)
2.6.1 Method signature
void pay(ULUOrder uluOrder, ULURole uluRole, ULUPayListenter uluPayListenter)
parameters |
explanation |
uluOrder |
Parameters required by SDK to create an order, can not be null |
uluRole |
Role-related parameters during payment, can not be null |
uluPayListenter |
It is different from the init listener, can not be null |
2.6.2 Code sample
ULUOrder uluOrder=new ULUOrder();
uluOrder.setExtraData("Transparent parameters, can not be empty");
uluOrder.setUluProductId("The product id in in-app purchase goods list");
ULURole uluRole=new ULURole();
uluRole.setRoleName("role name, can not be null");
uluRole.setServerName("server name, can not be null");
uluRole.setServerId("server id, can not be null");
uluRole.setRoleId("role id, can not be null");
ULUManager.getInstance().pay(uluOrder,uluRole,new ULUPayListenter() {
@Override
public void onPaySuccess(String orderId,String extraData) {
}
@Override
public void onPayFail(String orderId, String errorMsg,String extraData) {
}
});
2.7 User center (required)
Generally you need to add additional UI (such as a button) to use the calling method.
2.7.1 Method signature
void openUserCenter(ULURole uluRole, int orientation)
parameters |
explanation |
uluRole |
Role-related parameters |
orientation |
The screen orientation of game |
2.7.2 Code sample
ULURole uluRole = new ULURole();
uluRole.setRoleLevel("role level, can not be null");
uluRole.setRoleName("role name, can not be null");
uluRole.setRoleId("role id, can not be null");
uluRole.setServerName("server name, can not be null");
uluRole.setServerId("server id, can not be null");
uluRole.setVipLevel(1);
ULUManager.getInstance().openUserCenter(uluRole, ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
Google featuring requires that the currency displayed for in-game purchases must be consistent with the player's region, so this interface is provided to query in-game purchase information for development teams in need.
It is recommended that the game configure the in-game purchase price list by currency.
If you can determine the currency yourself, you do not need to call this method.
If the queried currency is in the configured currency, the corresponding currency should be displayed.
If the queried currency is not in the configured currency table or the query fails, the default currency should be displayed.
Note that this interface is only applicable to Google channel packages.
2.8.1 Method signature
void getProductList(ArrayList<String> uluProductIds, ULUGetProductListener uluQueryProductListener)
parameters |
explanation |
uluProductIds |
Any permanent product id |
uluQueryProductListener |
Callback |
2.8.2 Code sample
ArrayList<String> skuList = new ArrayList<String> ();
skuList.add("product id");
ULUManager.getInstance().getProductList(skuList, new ULUGetProductListener() {
@Override
public void onQuerySuccess(List<ULUProduct> list) {
String currency = uluProducts.get(0).getPayCurrency();
}
@Override
public void onQueryFail(String errorMsg) {
}
});
2.9 Customer Service Center (required)
Generally you need to add additional UI (such as a button) to use the calling method.
2.9.1 Method signature
void openCustomerService(ULURole uluRole, ULUOnCustomerServiceNewMessageListener listener)
parameters |
explanation |
uluRole |
Role-related parameters |
listener |
Customer service new message callback (optional) |
2.9.2 Code sample
ULURole uluRole = new ULURole();
uluRole.setRoleLevel("role level, can not be null");
uluRole.setRoleName("role name, can not be null");
uluRole.setRoleId("role id, can not be null");
uluRole.setServerName("server name, can not be null");
uluRole.setServerId("server id, can not be null");
uluRole.setVipLevel(1);
ULUManager.getInstance().openCustomerService(uluRole, new ULUOnCustomerServiceNewMessageListener() {
@Override
public void onCustomerServiceNewMessage() {
}
});
2.10 Track in-app events (required)
2.10.1 Setup application
public class YourApplication extends Application {
@Override
public synchronized void onCreate() {
super.onCreate();
SLSDatabaseManager.getInstance().setupDB(getApplicationContext());
}
}
2.10.2 Method signature
void uluTrackEvent(ULURole uluRole, String eventName, Map eventValues)
parameters |
explanation |
uluRole |
Role-related parameters, pass an empty ULURole object before any character has be selected, can not be null |
eventName |
event name, can not be empty |
eventValues |
can be null |
2.10.3 Code sample
ULURole uluRole = new ULURole();
uluRole.setRoleLevel("role level, can not be null");
uluRole.setRoleName("role name, can not be null");
uluRole.setRoleId("role id, can not be null");
uluRole.setServerName("server name, can not be null");
uluRole.setServerId("server id, can not be null");
uluRole.setVipLevel(1);
Map<String,String> map=new HashMap<String,String>();
map.put("key","value");
ULUManager.getInstance().uluTrackEvent(uluRole, "event_name", map);
2.11 Gift pack redemption (optional)
2.11.1 Method signature
void GiftPackDialog(Activity activity, ULURole uluRole)
parameters |
explanation |
activity |
Game activity, can not be null |
uluRole |
Role-related parameters, can not be null |
2.11.2 Code sample
ULURole uluRole = new ULURole();
uluRole.setRoleLevel("role level, can not be null");
uluRole.setRoleName("role name, can not be null");
uluRole.setRoleId("role id, can not be null");
uluRole.setServerName("server name, can not be null");
uluRole.setServerId("server id, can not be null");
uluRole.setVipLevel(1);
ULUManager.getInstance().GiftPackDialog(MainActivity.this,uluRole);
2.12 Questionnaire (optional)
Rewards only available when server has completed the gift pack distribution function.
2.12.1 Method signature
void openQuestionWeb(ULURole uluRole)
parameters |
explanation |
uluRole |
Role-related parameters, can not be null |
2.12.2 Code sample
ULURole uluRole = new ULURole();
uluRole.setRoleLevel("role level, can not be null");
uluRole.setRoleName("role name, can not be null");
uluRole.setRoleId("role id, can not be null");
uluRole.setServerName("server name, can not be null");
uluRole.setServerId("server id, can not be null");
uluRole.setVipLevel(1);
ULUManager.getInstance().openQuestionWeb(uluRole);
2.13 Google in-app review (optional)
2.13.1 Code sample
ULUManager.getInstance().inAppReview();
2.14.1 Method signature
void getCurrentUserAccountBindInfo(ULUGetCurrentUserAccountBindInfoListener listener)
parameters |
explanation |
listener |
callback |
2.14.2 Code sample
ULUManager.getInstance().getCurrentUserAccountBindInfo(new ULUGetCurrentUserAccountBindInfoListener() {
@Override
public void onFailed(int errorCode) {
}
@Override
public void onSuccess(ULUAccountBindInfo info) {
String email = info.getEmail();
String uid = info.getUid();
boolean isBind = info.isAnyBind();
boolean isBindGoogle = info.isBindGoogle();
}
});