---
title: "Track the progress and state of an offline pack download - Kotlin SDK | Mobile sdk | Mobile sdk android | Android"
description: "Offline API allows you to track the progress and state of an offline pack download."
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Track the progress and state of an offline pack download - Kotlin SDK

The MapTiler SDK for Kotlin provides a powerful Offline Pack API that allows you to track the progress and state of an offline pack download.

You can track the download state and progress reactively using Kotlin Flows.

Before you begin, ensure you have followed the [Android getting started with offline pack API](https://docs.maptiler.com/mobile-sdk/android/examples/offline-get-started/) to set up your project and obtain your API key.

## Tracking download progress

```kotlin
import com.maptiler.maptilersdk.offline.MTOfflineManager
import com.maptiler.maptilersdk.offline.MTOfflinePackState
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.launch

MainScope().launch {
    try {
        // Create the pack (assuming `definition` is already created)
        val pack = MTOfflineManager.createPack(context, definition)

        // Observe the state flow
        launch {
            pack.stateFlow.collect { state ->
                println("Pack state changed to: ${state.name}")
                if (state == MTOfflinePackState.COMPLETED) {
                    println("Download finished successfully!")
                }
            }
        }

        // Observe the progress flow
        launch {
            pack.progressFlow.collect { progress ->
                val percent = "%.1f".format(progress.percentage * 100)
                println("Download progress: $percent% (${progress.downloadedResources}/${progress.totalResources})")
            }
        }
        
        // Start the download
        pack.download()
    } catch (e: Exception) {
        e.printStackTrace()
    }
}
```

Tip

Alternatively, you can implement the `MTOfflineDownloadDelegate` and use `pack.setDelegate(observer)` alongside `pack.isProgressReportingEnabled = true` if you prefer a callback-based approach.

## Learn more

For more information browse our [API Reference](https://docs.maptiler.com/mobile-sdk/android/api/)

Check out our [SDK Kotlin Examples](https://docs.maptiler.com/mobile-sdk/android/examples/).
