navigationResumeSnapshot

Retrieves a NavigationResumeSnapshot for the ongoing navigation session. This can be persisted to support resuming the navigation session when the application is restarted.

Important: This is a Public Preview API. It may be changed or removed at any time.

To improve performance, save the `NavigationResumeSnapshot` after the key events that bring significant changes in the navigation state, such as:

  • Starting navigation along a route.

  • Refreshing the route.

  • Deviating from the route.

  • Visiting a waypoint.

If you want to save NavigationResumeSnapshot as a file you can use the following snippet:

val fileName = "navigation_snapshot"
tomTomNavigation.navigationResumeSnapshot()
.ifSuccess { snapshot ->
snapshot.serialize()
.ifSuccess { data ->
val file = File(context.filesDir, fileName)
FileOutputStream(file).use { fileOutputStream ->
fileOutputStream.write(data.toByteArray())
}
}
.ifFailure { failure: NavigationResumeSnapshotSerializationFailure ->
println("An error occurred: $failure")
}
}
.ifFailure { failure: NavigationResumeSnapshotFailure ->
println("An error occurred: $failure")
}

To resume a navigation session with a given NavigationResumeSnapshot, see TomTomNavigation.resume.

Throws

if the instance of TomTomNavigation has been closed before.