Skip to main content
Version: 2.x.x

Initialization

Activity

Add the following methods to your Activity.

// Java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Platform101XP.Companion.onCreate(this);
}

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

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

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

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

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

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

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

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

// Kotlin
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
Platform101XP.onCreate(this)
}

override fun onStart() {
super.onStart()
Platform101XP.onStart(this)
}

override fun onResume() {
super.onResume()
Platform101XP.onResume(this)
}

override fun onPause() {
super.onPause()
Platform101XP.onPause(this)
}

override fun onDestroy() {
super.onDestroy()
Platform101XP.onDestroy(this)
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
Platform101XP.onActivityResult(requestCode, resultCode, data)
}

override fun onSaveInstanceState(savedInstanceState: Bundle) {
Platform101XP.onSaveInstanceState(savedInstanceState)
}

override fun onRestoreInstanceState(savedInstanceState: Bundle) {
Platform101XP.onRestoreInstanceState(savedInstanceState)
}

override fun 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.

//Java
Platform101XP.Companion.initialize(listener);

// Kotlin
Platform101XP.initialize(listener)
caution

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

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

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

// Kotlin
override fun onCreate(savedInstanceState: Bundle?) {
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()

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

// Kotlin
fun someMethod(){
if (Platform101XP.isInitialized()) {
//... do something
}
}