Event listeners
Register a NaviHelperEventListener to receive API request results and navigation-state changes.
Event categories
| Category | Callback |
|---|---|
| Route search | onRouteStarted(), onRoutingCompleted(), onRouteCancelled(), onReRouteEnded(), onRouteOptionChanged() |
| Destinations and waypoints | onDestinationChanged(), onDestinationArrived(), onWaypointChanged(), onWayPointArrived() |
| Information requests | onBookmarkInfo(), onBookMarkChanged(), onRecentDestinationInfo(), onCurrentLocationInfo(), onDestinationInfo(), onWayPointInfo(), onRouteStateInfo(), onTBTInfo(), onChargerOperatorInfo(), onTripInfo(), onNavigationStatus(), onDrivingInfo(), onCurrentRoadSpeedLimit(), onCameraAlert(), onCautionPointInfo() |
| Errors | onError() |
The events that are delivered may vary depending on the Navigation app's implementation scenarios.
Add a listener
Override only the callbacks your app needs, and register the listener after initializing the SDK.
- Kotlin
- Java
import ai.pleos.playground.navi.constants.NaviErrorCode
import ai.pleos.playground.navi.data.RouteStartInfo
import ai.pleos.playground.navi.helper.listener.NaviHelperEventListener
private val naviEventListener = object : NaviHelperEventListener {
override fun onRouteStarted(routeStartInfo: RouteStartInfo) {
// Handle the start of a route search.
}
override fun onRoutingCompleted() {
// Handle route search completion.
}
override fun onError(errorCode: NaviErrorCode) {
// Handle the navigation error.
}
}
naviHelper.addListener(naviEventListener)
private final NaviHelperEventListener naviEventListener =
new NaviHelperEventListener() {
@Override
public void onRouteStarted(RouteStartInfo routeStartInfo) {
// Handle the start of a route search.
}
@Override
public void onRoutingCompleted() {
// Handle route search completion.
}
@Override
public void onError(NaviErrorCode errorCode) {
// Handle the navigation error.
}
};
naviHelper.addListener(naviEventListener);
Remove a listener
When the listener is no longer needed, or before releasing the SDK, remove the same listener instance that was registered.
naviHelper.removeListener(naviEventListener)
For error-specific handling, see Error handling.