Monitor Download Progress

This guide explains how to monitor download progress to track route-network, map-tile, and overall region’s state. Subsequently, it explains how to use these states to decide when offline routing, offline map display, or the complete offline navigation experience is available.

1
private fun renderDownloadProgress(items: List<OfflineRegionProgress>) {
2
items.forEach { progress ->
3
val routeReady =
4
progress.routeNetwork?.state == OfflineTaskState.COMPLETED
5
val mapReady =
6
progress.mapTile?.state == OfflineTaskState.COMPLETED
7
8
updateRegionRow(
9
regionId = progress.regionId,
10
percent = progress.overallPercent.coerceIn(0, 100),
11
state = progress.overallState,
12
routeReady = routeReady,
13
mapReady = mapReady
14
)
15
}
16
}
StateRecommended UI
NOT_STARTEDNot started
QUEUEDWaiting to download
RUNNINGShow the percentage and a downloading state
PAUSEDShow a paused state and a “Resume” button
PARTIALShow an incomplete state and a “Resume” button
FAILEDShow the error and a “Retry” button
COMPLETEDThis subtask is complete

routeNetwork at COMPLETED means that offline routing is available while mapTile at COMPLETED means that the offline basemap is available.

After an application restart, call initialize() and observe progress again to restore persisted state. Do not create another download task because a screen was recreated. Calling cancel() on the subscription handle removes only that screen's listener but it does not cancel the download.