Skip to main content
Version: 1.49.x

Usage

Activity โ€‹

Add the following methods to your Activity.

@Override
protected void onCreate() {
super.onCreate();
Platform101XP.onCreate(this);
}

@Override
protected void onStart() {
super.onStart();
Platform101XP.onStart(this);
}

@Override
protected void onResume() {
super.onResume();
Platform101XP.onResume(this);
}

@Override
protected void onPause() {
super.onPause();
Platform101XP.onPause(this);
}

@Override
protected void onDestroy() {
super.onDestroy();
Platform101XP.onDestroy(this);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Platform101XP.onActivityResult(requestCode, resultCode, data);
}

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
Platform101XP.onSaveInstanceState(savedInstanceState);
}

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
Platform101XP.onRestoreInstanceState(savedInstanceState);
}

@Override
public void onBackPressed() {
Platform101XP.backPressed();
}

Initializationโ€‹

To initialize the SDK, call this method.

The listener objectโ€™s methods are called when events occur within the SDK. The listener class must implement the Platform101XPListener interface.

Platform101XP.initialize(listener);
caution

Platform101XP.initialize(listener) should be called in method onCreate() activity after calling Platform101XP.onCreate(this):

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Initialize 101XP SDK.
Platform101XP.onCreate(this);
Platform101XP.initialize(listener);
}

You can get ERROR_NOT_INITIALIZED in listener methods. If you want to check that sdk is initialized call the method Platform101XP.isInitialized()

public void someMethod(){
if(Platform101XP.isInitialized()){
//... do something
}
}

User Authorization โ€‹

The method for authorizing users. A result or an error are sent to method onAuthorizeResult.

  1. By default, the method uses guest authorization.
  2. After 24h since the first authorization "Save progress" window appears.
  3. If a user has been authorized before, then the token refreshes by calling onAuthorizeResult.
Platform101XP.authorize();

The method for userโ€™s profile display. The result of the authorization or an error is passed to method OnAuthorizeResult.

Platform101XP.showProfile();
Deprecated

Method Platform101XP.managedAuthorize() is deprecated, please use Platform101XP.showProfile() method.

SDK events processingโ€‹

The result of the authorization attempt is sent to the listener method after calling Platform101XP.authorize() or Platform101XP.showProfile().

  1. In case of successful authorization, token is sent to the method.
  2. In case of an error, error is sent to the method.
void onAuthorizeResult(Platform101XPToken token, Platform101XPError error);

and if successful authorization information about the account will come.

void onGetAccountResult(Platform101XPAccount account, Platform101XPError error);

Handling an event when a player clicks Cancel buttonโ€‹

To handle this event onAuthorizeResult is used:

public void onAuthorizeResult(Platform101XPToken token, Platform101XPError error) {
if(error.getErrorType() == Platform101XPError.ErrorType.ERROR_CANCELED){
showMessage("Action canceled!");
}
}

Connection errorโ€‹

If a user does not have an internet connection the method onAuthorizeResult will return ERROR_CONNECTION.

public void onAuthorizeResult(Platform101XPToken token, Platform101XPError error) {
if(error.getErrorType() == Platform101XPError.ErrorType.ERROR_CONNECTION){
showMessage("Connection error!");
}
}

User logoutโ€‹

To handle this event use method onLogout() from listener.Platform101XPListener.

@Override
public void onLogout() {
// Do something after logout
}