Initialization
When the app starts or is created, create a NaviHelper object and call initialize() before using the NaviHelper APIs.
Initialize the SDK
initialize() provides two overloads.
| Overload | Description |
|---|---|
initialize(onConnected, onFailed) | Receives the service connection result through callbacks. onConnected is called when the first service connection is established, and onFailed is called when the initial connection retries are exhausted. |
initialize() | Initializes the SDK with no arguments. |
Other APIs work correctly only after initialization. Prefer the API that provides connection-state callbacks.
- Kotlin
- Java
import ai.pleos.playground.navi.helper.NaviHelper
val naviHelper = NaviHelper(applicationContext)
naviHelper.initialize(
onConnected = {
// The first service connection succeeded. Register listeners and call APIs.
},
onFailed = { throwable ->
// The initial connection retries were exhausted.
}
)
import ai.pleos.playground.navi.helper.NaviHelper;
import kotlin.Unit;
NaviHelper naviHelper = new NaviHelper(getApplicationContext());
naviHelper.initialize(
() -> {
// The first service connection succeeded. Register listeners and call APIs.
return Unit.INSTANCE;
},
throwable -> {
// The initial connection retries were exhausted.
return Unit.INSTANCE;
}
);
You can also call the no-argument initialize().
naviHelper.initialize()
Release the SDK
When the SDK is no longer needed, remove registered listeners and call release().
- Kotlin
- Java
override fun onDestroy() {
naviHelper.removeListener(naviEventListener)
naviHelper.release()
super.onDestroy()
}
@Override
protected void onDestroy() {
naviHelper.removeListener(naviEventListener);
naviHelper.release();
super.onDestroy();
}
To use the SDK after release(), create the object again and repeat the initialization steps.