# DownloadManager.Listener

Artifact: [androidx.media3:media3-exoplayer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/offline/DownloadManager.java+class:androidx.media3.exoplayer.offline.DownloadManager.Listener)

*** ** * ** ***


```
public interface DownloadManager.Listener
```

<br />

Known direct subclasses [TestDownloadManagerListener](https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestDownloadManagerListener)

|---|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/robolectric/TestDownloadManagerListener` | Allows tests to block for, and assert properties of, calls from a `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager` to its `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager.Listener`. |

*** ** * ** ***

Listener for `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager` events.

## Summary

| ### Public methods |
|---|---|
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager.Listener#onDownloadChanged(androidx.media3.exoplayer.offline.DownloadManager,androidx.media3.exoplayer.offline.Download,java.lang.Exception)( https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager downloadManager, https://developer.android.com/reference/androidx/media3/exoplayer/offline/Download download, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Exception.html finalException )` Called when the state of a download changes. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager.Listener#onDownloadRemoved(androidx.media3.exoplayer.offline.DownloadManager,androidx.media3.exoplayer.offline.Download)(https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager downloadManager, https://developer.android.com/reference/androidx/media3/exoplayer/offline/Download download)` Called when a download is removed. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager.Listener#onDownloadsPausedChanged(androidx.media3.exoplayer.offline.DownloadManager,boolean)( https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager downloadManager, boolean downloadsPaused )` Called when downloads are (`https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager#pauseDownloads()` or `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager#resumeDownloads()`. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager.Listener#onIdle(androidx.media3.exoplayer.offline.DownloadManager)(https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager downloadManager)` Called when there is no active download left. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager.Listener#onInitialized(androidx.media3.exoplayer.offline.DownloadManager)(https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager downloadManager)` Called when all downloads have been restored. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager.Listener#onRequirementsStateChanged(androidx.media3.exoplayer.offline.DownloadManager,androidx.media3.exoplayer.scheduler.Requirements,int)( https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager downloadManager, https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Requirements requirements, @https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Requirements.RequirementFlags int notMetRequirements )` Called when the download requirements state changed. |
| `default void` | `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager.Listener#onWaitingForRequirementsChanged(androidx.media3.exoplayer.offline.DownloadManager,boolean)( https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager downloadManager, boolean waitingForRequirements )` Called when there is a change in whether this manager has one or more downloads that are not progressing for the sole reason that the `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager#getRequirements()` are not met. |

## Public methods

### onDownloadChanged

```
default void onDownloadChanged(
    DownloadManager downloadManager,
    Download download,
    @Nullable Exception finalException
)
```

Called when the state of a download changes.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager downloadManager` | The reporting instance. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/Download download` | The state of the download. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Exception.html finalException` | If the download is transitioning to `https://developer.android.com/reference/androidx/media3/exoplayer/offline/Download#STATE_FAILED()`, this is the final exception that resulted in the failure. |

### onDownloadRemoved

```
default void onDownloadRemoved(DownloadManager downloadManager, Download download)
```

Called when a download is removed.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager downloadManager` | The reporting instance. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/Download download` | The last state of the download before it was removed. |

### onDownloadsPausedChanged

```
default void onDownloadsPausedChanged(
    DownloadManager downloadManager,
    boolean downloadsPaused
)
```

Called when downloads are (`https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager#pauseDownloads()` or `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager#resumeDownloads()`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager downloadManager` | The reporting instance. |
| `boolean downloadsPaused` | Whether downloads are currently paused. |

### onIdle

```
default void onIdle(DownloadManager downloadManager)
```

Called when there is no active download left.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager downloadManager` | The reporting instance. |

### onInitialized

```
default void onInitialized(DownloadManager downloadManager)
```

Called when all downloads have been restored.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager downloadManager` | The reporting instance. |

### onRequirementsStateChanged

```
default void onRequirementsStateChanged(
    DownloadManager downloadManager,
    Requirements requirements,
    @Requirements.RequirementFlags int notMetRequirements
)
```

Called when the download requirements state changed.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager downloadManager` | The reporting instance. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Requirements requirements` | Requirements needed to be met to start downloads. |
| `@https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Requirements.RequirementFlags int notMetRequirements` | `https://developer.android.com/reference/androidx/media3/exoplayer/scheduler/Requirements.RequirementFlags` that are not met, or 0. |

### onWaitingForRequirementsChanged

```
default void onWaitingForRequirementsChanged(
    DownloadManager downloadManager,
    boolean waitingForRequirements
)
```

Called when there is a change in whether this manager has one or more downloads that are not progressing for the sole reason that the `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager#getRequirements()` are not met. See `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager#isWaitingForRequirements()` for more information.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager downloadManager` | The reporting instance. |
| `boolean waitingForRequirements` | Whether this manager has one or more downloads that are not progressing for the sole reason that the `https://developer.android.com/reference/androidx/media3/exoplayer/offline/DownloadManager#getRequirements()` are not met. |