Skip to main content

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.

OverloadDescription
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.

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.
}
)

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().

override fun onDestroy() {
naviHelper.removeListener(naviEventListener)
naviHelper.release()
super.onDestroy()
}

To use the SDK after release(), create the object again and repeat the initialization steps.