navigationResumeSnapshot
abstract fun navigationResumeSnapshot(): Result<NavigationResumeSnapshot, NavigationResumeSnapshotFailure>
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"
val file = File(context.filesDir, fileName)
tomTomNavigation.navigationResumeSnapshot()
.ifSuccess { snapshot ->
snapshot.serializeToFile() //Or snapshot.serializeToBytes()
.ifSuccess { data ->
FileOutputStream(file).use { fileOutputStream ->
fileOutputStream.write(data.toByteArray())
}
}
.ifFailure { failure: NavigationResumeSnapshotSerializationFailure ->
println("An error occurred: $failure")
}
}
.ifFailure { failure: NavigationResumeSnapshotFailure ->
println("An error occurred: $failure")
}
Content copied to clipboard
To resume a navigation session with a given NavigationResumeSnapshot, see TomTomNavigation.resume.
Throws
if the instance of TomTomNavigation is closed.