Error handling
NaviHelper reports initial service connection failures and Navigation app request errors through different paths.
Initialization failures
Pass callbacks to initialize() when your app needs the initial connection result.
naviHelper.initialize(
onConnected = {
// Register a listener and call an API.
},
onFailed = { throwable ->
// Log the connection failure or notify the user.
}
)
Navigation errors
Errors from the Navigation app are delivered through NaviHelperEventListener.onError().
override fun onError(errorCode: NaviErrorCode) {
when (errorCode) {
NaviErrorCode.CAUSE_LOW_BATTERY -> {
// Notify the user that the battery level is low.
}
NaviErrorCode.CAUSE_SEARCH_ROUTE_OVER_DISTANCE -> {
// Notify the user that the route exceeds the searchable distance.
}
NaviErrorCode.CAUSE_SEARCH_ROUTE_TOO_SHORT_DISTANCE -> {
// Notify the user that the destination is too close.
}
NaviErrorCode.CAUSE_SEARCH_ROUTE -> {
// Handle the route search server error.
}
}
}
Error codes
| Error code | Description |
|---|---|
CAUSE_LOW_BATTERY | The battery level is low. |
CAUSE_SEARCH_ROUTE_OVER_DISTANCE | The route exceeds the maximum searchable distance. |
CAUSE_SEARCH_ROUTE_TOO_SHORT_DISTANCE | The destination is too close to the current location. |
CAUSE_SEARCH_ROUTE | A route search server error occurred. |
When an error occurs, also check the following:
- The API was called after the SDK connection was established.
- The permissions required by the API are declared.
- The coordinates, POI ID, and waypoint index are valid.
- The Navigation app can process the request in its current state.
For the latest error code list, see the NaviHelper API Reference.