Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/telephony/MbmsDownloadSession#constants) \| [Methods](https://developer.android.com/reference/android/telephony/MbmsDownloadSession#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/telephony/MbmsDownloadSession#inhmethods)

# MbmsDownloadSession

*** ** * ** ***

` public class MbmsDownloadSession `   
` extends https://developer.android.com/reference/java/lang/Object ` ` implements https://developer.android.com/reference/java/lang/AutoCloseable `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.telephony.MbmsDownloadSession |

<br />

*** ** * ** ***

This class provides functionality for file download over MBMS.

## Summary

| ### Constants ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#DEFAULT_TOP_LEVEL_TEMP_DIRECTORY` The default directory name for all MBMS temp files. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#EXTRA_MBMS_COMPLETED_FILE_URI` `https://developer.android.com/reference/android/net/Uri` extra that Android will attach to the intent supplied via `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest.Builder#setAppIntent(android.content.Intent)` Indicates the location of the successfully downloaded file within the directory that the app provided via the builder. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#EXTRA_MBMS_DOWNLOAD_REQUEST` Extra containing the `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest` for which the download result or file descriptor request is for. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#EXTRA_MBMS_DOWNLOAD_RESULT` Integer extra that Android will attach to the intent supplied via `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest.Builder#setAppIntent(android.content.Intent)` Indicates the result code of the download. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#EXTRA_MBMS_FILE_INFO` `https://developer.android.com/reference/android/telephony/mbms/FileInfo` extra that Android will attach to the intent supplied via `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest.Builder#setAppIntent(android.content.Intent)` Indicates the file for which the download result is for. |
| `int` | `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#RESULT_CANCELLED` Indicates that the download was cancelled via `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#cancelDownload(android.telephony.mbms.DownloadRequest)`. |
| `int` | `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#RESULT_DOWNLOAD_FAILURE` Indicates that there was an error while processing downloaded files, such as a file repair or file decoding error and is not due to a file I/O error. |
| `int` | `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#RESULT_EXPIRED` Indicates that the download will not be completed due to the expiration of its download window on the carrier's network. |
| `int` | `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#RESULT_FILE_ROOT_UNREACHABLE` Indicates that the file root that was set is currently unreachable. |
| `int` | `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#RESULT_IO_ERROR` Indicates that the download will not be completed due to an I/O error incurred while writing to temp files. |
| `int` | `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#RESULT_OUT_OF_STORAGE` Indicates that the file system is full and the `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest` can not complete. |
| `int` | `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#RESULT_SERVICE_ID_NOT_DEFINED` Indicates that the Service ID specified in the `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest` is incorrect due to the Id being incorrect, stale, expired, or similar. |
| `int` | `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#RESULT_SUCCESSFUL` Indicates that the download was successful. |
| `int` | `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#STATUS_ACTIVELY_DOWNLOADING` Indicates that the file is actively being downloaded. |
| `int` | `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#STATUS_PENDING_DOWNLOAD` Indicates that the file is awaiting the next download or repair operations. |
| `int` | `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#STATUS_PENDING_DOWNLOAD_WINDOW` Indicates that the file is waiting to download because its download window has not yet started and is scheduled for a future time. |
| `int` | `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#STATUS_PENDING_REPAIR` Indicates that the file is awaiting file repair after the download has ended. |
| `int` | `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#STATUS_UNKNOWN` Indicates that the middleware has no information on the file. |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/telephony/MbmsDownloadSession#addProgressListener(android.telephony.mbms.DownloadRequest,%20java.util.concurrent.Executor,%20android.telephony.mbms.DownloadProgressListener)(https://developer.android.com/reference/android/telephony/mbms/DownloadRequest request, https://developer.android.com/reference/java/util/concurrent/Executor executor, https://developer.android.com/reference/android/telephony/mbms/DownloadProgressListener listener) ` Registers a progress listener for a `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest` previously requested via `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#download(android.telephony.mbms.DownloadRequest)`. |
| ` void` | ` https://developer.android.com/reference/android/telephony/MbmsDownloadSession#addServiceAnnouncement(byte[])(byte[] contents) ` Inform the middleware of a service announcement descriptor received from a group communication server. |
| ` void` | ` https://developer.android.com/reference/android/telephony/MbmsDownloadSession#addStatusListener(android.telephony.mbms.DownloadRequest,%20java.util.concurrent.Executor,%20android.telephony.mbms.DownloadStatusListener)(https://developer.android.com/reference/android/telephony/mbms/DownloadRequest request, https://developer.android.com/reference/java/util/concurrent/Executor executor, https://developer.android.com/reference/android/telephony/mbms/DownloadStatusListener listener) ` Registers a download status listener for a `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest` previously requested via `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#download(android.telephony.mbms.DownloadRequest)`. |
| ` void` | ` https://developer.android.com/reference/android/telephony/MbmsDownloadSession#cancelDownload(android.telephony.mbms.DownloadRequest)(https://developer.android.com/reference/android/telephony/mbms/DownloadRequest downloadRequest) ` Attempts to cancel the specified `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest`. |
| ` void` | ` https://developer.android.com/reference/android/telephony/MbmsDownloadSession#close()() ` Terminates this instance. |
| ` static https://developer.android.com/reference/android/telephony/MbmsDownloadSession` | ` https://developer.android.com/reference/android/telephony/MbmsDownloadSession#create(android.content.Context,%20java.util.concurrent.Executor,%20int,%20android.telephony.mbms.MbmsDownloadSessionCallback)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/java/util/concurrent/Executor executor, int subscriptionId, https://developer.android.com/reference/android/telephony/mbms/MbmsDownloadSessionCallback callback) ` Create a new MbmsDownloadManager using the given subscription ID. |
| ` static https://developer.android.com/reference/android/telephony/MbmsDownloadSession` | ` https://developer.android.com/reference/android/telephony/MbmsDownloadSession#create(android.content.Context,%20java.util.concurrent.Executor,%20android.telephony.mbms.MbmsDownloadSessionCallback)(https://developer.android.com/reference/android/content/Context context, https://developer.android.com/reference/java/util/concurrent/Executor executor, https://developer.android.com/reference/android/telephony/mbms/MbmsDownloadSessionCallback callback) ` Create a new `https://developer.android.com/reference/android/telephony/MbmsDownloadSession` using the system default data subscription ID. |
| ` void` | ` https://developer.android.com/reference/android/telephony/MbmsDownloadSession#download(android.telephony.mbms.DownloadRequest)(https://developer.android.com/reference/android/telephony/mbms/DownloadRequest request) ` Requests the download of a file or set of files that the carrier has indicated to be available. |
| ` static int` | ` https://developer.android.com/reference/android/telephony/MbmsDownloadSession#getMaximumServiceAnnouncementSize()() ` Returns the maximum size of the service announcement descriptor that can be provided via `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#addServiceAnnouncement(byte[])` |
| ` https://developer.android.com/reference/java/io/File` | ` https://developer.android.com/reference/android/telephony/MbmsDownloadSession#getTempFileRootDirectory()() ` Retrieves the currently configured temp file root directory. |
| ` https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/telephony/mbms/DownloadRequest>` | ` https://developer.android.com/reference/android/telephony/MbmsDownloadSession#listPendingDownloads()() ` Returns a list of pending `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest`s that originated from this application. |
| ` void` | ` https://developer.android.com/reference/android/telephony/MbmsDownloadSession#removeProgressListener(android.telephony.mbms.DownloadRequest,%20android.telephony.mbms.DownloadProgressListener)(https://developer.android.com/reference/android/telephony/mbms/DownloadRequest request, https://developer.android.com/reference/android/telephony/mbms/DownloadProgressListener listener) ` Un-register a listener previously registered via `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#addProgressListener(android.telephony.mbms.DownloadRequest,%20java.util.concurrent.Executor,%20android.telephony.mbms.DownloadProgressListener)`. |
| ` void` | ` https://developer.android.com/reference/android/telephony/MbmsDownloadSession#removeStatusListener(android.telephony.mbms.DownloadRequest,%20android.telephony.mbms.DownloadStatusListener)(https://developer.android.com/reference/android/telephony/mbms/DownloadRequest request, https://developer.android.com/reference/android/telephony/mbms/DownloadStatusListener listener) ` Un-register a listener previously registered via `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#addStatusListener(android.telephony.mbms.DownloadRequest,%20java.util.concurrent.Executor,%20android.telephony.mbms.DownloadStatusListener)`. |
| ` void` | ` https://developer.android.com/reference/android/telephony/MbmsDownloadSession#requestDownloadState(android.telephony.mbms.DownloadRequest,%20android.telephony.mbms.FileInfo)(https://developer.android.com/reference/android/telephony/mbms/DownloadRequest downloadRequest, https://developer.android.com/reference/android/telephony/mbms/FileInfo fileInfo) ` Requests information about the state of a file pending download. |
| ` void` | ` https://developer.android.com/reference/android/telephony/MbmsDownloadSession#requestUpdateFileServices(java.util.List<java.lang.String>)(https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/String> classList) ` An inspection API to retrieve the list of available `https://developer.android.com/reference/android/telephony/mbms/FileServiceInfo`s currently being advertised. |
| ` void` | ` https://developer.android.com/reference/android/telephony/MbmsDownloadSession#resetDownloadKnowledge(android.telephony.mbms.DownloadRequest)(https://developer.android.com/reference/android/telephony/mbms/DownloadRequest downloadRequest) ` Resets the middleware's knowledge of previously-downloaded files in this download request. |
| ` void` | ` https://developer.android.com/reference/android/telephony/MbmsDownloadSession#setTempFileRootDirectory(java.io.File)(https://developer.android.com/reference/java/io/File tempFileRootDirectory) ` Sets the temp file root for downloads. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.
From interface ` https://developer.android.com/reference/java/lang/AutoCloseable ` ` abstract void` ` https://developer.android.com/reference/java/lang/AutoCloseable#close()() `

Closes this resource, relinquishing any underlying resources.

## Constants

### DEFAULT_TOP_LEVEL_TEMP_DIRECTORY

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String DEFAULT_TOP_LEVEL_TEMP_DIRECTORY
```

The default directory name for all MBMS temp files. If you call `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#download(android.telephony.mbms.DownloadRequest)` without first calling `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#setTempFileRootDirectory(java.io.File)`, this directory will be created for you under the path returned by `https://developer.android.com/reference/android/content/Context#getFilesDir()`.

<br />

Constant Value: "androidMbmsTempFileRoot"

### EXTRA_MBMS_COMPLETED_FILE_URI

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_MBMS_COMPLETED_FILE_URI
```

`https://developer.android.com/reference/android/net/Uri` extra that Android will attach to the intent supplied via `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest.Builder#setAppIntent(android.content.Intent)` Indicates the location of the successfully downloaded file within the directory that the app provided via the builder. Will always be set to a non-null value if `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#EXTRA_MBMS_DOWNLOAD_RESULT` is set to `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#RESULT_SUCCESSFUL`.

<br />

Constant Value: "android.telephony.extra.MBMS_COMPLETED_FILE_URI"

### EXTRA_MBMS_DOWNLOAD_REQUEST

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_MBMS_DOWNLOAD_REQUEST
```

Extra containing the `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest` for which the download result or file descriptor request is for. Must not be null.

<br />

Constant Value: "android.telephony.extra.MBMS_DOWNLOAD_REQUEST"

### EXTRA_MBMS_DOWNLOAD_RESULT

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_MBMS_DOWNLOAD_RESULT
```

Integer extra that Android will attach to the intent supplied via `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest.Builder#setAppIntent(android.content.Intent)` Indicates the result code of the download. One of `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#RESULT_SUCCESSFUL`, `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#RESULT_EXPIRED`, `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#RESULT_CANCELLED`, `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#RESULT_IO_ERROR`, `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#RESULT_DOWNLOAD_FAILURE`, `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#RESULT_OUT_OF_STORAGE`, `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#RESULT_SERVICE_ID_NOT_DEFINED`, or `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#RESULT_FILE_ROOT_UNREACHABLE`. This extra may also be used by the middleware when it is sending intents to the app.

<br />

Constant Value: "android.telephony.extra.MBMS_DOWNLOAD_RESULT"

### EXTRA_MBMS_FILE_INFO

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String EXTRA_MBMS_FILE_INFO
```

`https://developer.android.com/reference/android/telephony/mbms/FileInfo` extra that Android will attach to the intent supplied via `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest.Builder#setAppIntent(android.content.Intent)` Indicates the file for which the download result is for. Never null. This extra may also be used by the middleware when it is sending intents to the app.

<br />

Constant Value: "android.telephony.extra.MBMS_FILE_INFO"

### RESULT_CANCELLED

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RESULT_CANCELLED
```

Indicates that the download was cancelled via `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#cancelDownload(android.telephony.mbms.DownloadRequest)`.

<br />

Constant Value: 2 (0x00000002)

### RESULT_DOWNLOAD_FAILURE

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RESULT_DOWNLOAD_FAILURE
```

Indicates that there was an error while processing downloaded files, such as a file repair or file decoding error and is not due to a file I/O error. This is likely a transient error and another `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest` should be sent to try the download again.

<br />

Constant Value: 6 (0x00000006)

### RESULT_EXPIRED

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RESULT_EXPIRED
```

Indicates that the download will not be completed due to the expiration of its download window on the carrier's network.

<br />

Constant Value: 3 (0x00000003)

### RESULT_FILE_ROOT_UNREACHABLE

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RESULT_FILE_ROOT_UNREACHABLE
```

Indicates that the file root that was set is currently unreachable. This can happen if the temp files are set to be stored on external storage and the SD card was removed, for example. The temp file root should be changed before sending another DownloadRequest.

<br />

Constant Value: 8 (0x00000008)

### RESULT_IO_ERROR

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RESULT_IO_ERROR
```

Indicates that the download will not be completed due to an I/O error incurred while writing to temp files. This is likely a transient error and another `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest` should be sent to try the download again.

<br />

Constant Value: 4 (0x00000004)

### RESULT_OUT_OF_STORAGE

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RESULT_OUT_OF_STORAGE
```

Indicates that the file system is full and the `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest` can not complete. Either space must be made on the current file system or the temp file root location must be changed to a location that is not full to download the temp files.

<br />

Constant Value: 7 (0x00000007)

### RESULT_SERVICE_ID_NOT_DEFINED

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RESULT_SERVICE_ID_NOT_DEFINED
```

Indicates that the Service ID specified in the `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest` is incorrect due to the Id being incorrect, stale, expired, or similar.

<br />

Constant Value: 5 (0x00000005)

### RESULT_SUCCESSFUL

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int RESULT_SUCCESSFUL
```

Indicates that the download was successful.

<br />

Constant Value: 1 (0x00000001)

### STATUS_ACTIVELY_DOWNLOADING

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int STATUS_ACTIVELY_DOWNLOADING
```

Indicates that the file is actively being downloaded.

<br />

Constant Value: 1 (0x00000001)

### STATUS_PENDING_DOWNLOAD

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int STATUS_PENDING_DOWNLOAD
```

Indicates that the file is awaiting the next download or repair operations. When a more precise status is known, the status will change to either `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#STATUS_PENDING_REPAIR` or `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#STATUS_PENDING_DOWNLOAD_WINDOW`.

<br />

Constant Value: 2 (0x00000002)

### STATUS_PENDING_DOWNLOAD_WINDOW

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int STATUS_PENDING_DOWNLOAD_WINDOW
```

Indicates that the file is waiting to download because its download window has not yet started and is scheduled for a future time.

<br />

Constant Value: 4 (0x00000004)

### STATUS_PENDING_REPAIR

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int STATUS_PENDING_REPAIR
```

Indicates that the file is awaiting file repair after the download has ended.

<br />

Constant Value: 3 (0x00000003)

### STATUS_UNKNOWN

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final int STATUS_UNKNOWN
```

Indicates that the middleware has no information on the file.

<br />

Constant Value: 0 (0x00000000)

## Public methods

### addProgressListener

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void addProgressListener (DownloadRequest request, 
                Executor executor, 
                DownloadProgressListener listener)
```

Registers a progress listener for a `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest` previously requested via `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#download(android.telephony.mbms.DownloadRequest)`. This listener will only be called as long as both this app and the middleware are both running -- if either one stops, no further calls on the provided `https://developer.android.com/reference/android/telephony/mbms/DownloadProgressListener` will be enqueued. If the middleware is not aware of the specified download request, this method will throw an `https://developer.android.com/reference/java/lang/IllegalArgumentException`. If the operation encountered an error, the error code will be delivered via `https://developer.android.com/reference/android/telephony/mbms/MbmsDownloadSessionCallback#onError(int,%20java.lang.String)`. Repeated calls to this method for the same `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest` will replace the previously registered listener.

<br />

| Parameters ||
|---|---|
| `request` | `DownloadRequest`: The `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest` that you want updates on. This value cannot be `null`. <br /> |
| `executor` | `Executor`: The `https://developer.android.com/reference/java/util/concurrent/Executor` on which calls to `listener` should be executed. This value cannot be `null`. <br /> |
| `listener` | `DownloadProgressListener`: The listener that should be called when the middleware has information to share on the progress of the download. This value cannot be `null`. <br /> |

### addServiceAnnouncement

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void addServiceAnnouncement (byte[] contents)
```

Inform the middleware of a service announcement descriptor received from a group communication server. When participating in a group call via the `https://developer.android.com/reference/android/telephony/MbmsGroupCallSession` API, applications may receive a service announcement descriptor from the group call server that informs them of files that may be relevant to users communicating on the group call. After supplying the service announcement descriptor received from the server to the middleware via this API, applications will receive information on the available files via `https://developer.android.com/reference/android/telephony/mbms/MbmsDownloadSessionCallback#onFileServicesUpdated(java.util.List<android.telephony.mbms.FileServiceInfo>)`, and the available files will be downloadable via `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#download(android.telephony.mbms.DownloadRequest)` like other files published via `https://developer.android.com/reference/android/telephony/mbms/MbmsDownloadSessionCallback#onFileServicesUpdated(java.util.List<android.telephony.mbms.FileServiceInfo>)`. Asynchronous error codes via the `https://developer.android.com/reference/android/telephony/mbms/MbmsDownloadSessionCallback#onError(int,%20java.lang.String)` callback may include any of the errors that are not specific to the streaming use-case. May throw an `https://developer.android.com/reference/java/lang/IllegalStateException` when the middleware has not yet been bound, or an `https://developer.android.com/reference/java/lang/IllegalArgumentException` if the byte array is too large, or an `https://developer.android.com/reference/java/lang/UnsupportedOperationException` if the middleware has not implemented this method.

<br />

| Parameters ||
|---|---|
| `contents` | `byte`: The contents of the service announcement descriptor received from the group call server. If the size of this array is greater than the value of `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#getMaximumServiceAnnouncementSize()`, an `https://developer.android.com/reference/java/lang/IllegalArgumentException` will be thrown. This value cannot be `null`. <br /> |

### addStatusListener

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void addStatusListener (DownloadRequest request, 
                Executor executor, 
                DownloadStatusListener listener)
```

Registers a download status listener for a `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest` previously requested via `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#download(android.telephony.mbms.DownloadRequest)`. This callback will only be called as long as both this app and the middleware are both running -- if either one stops, no further calls on the provided `https://developer.android.com/reference/android/telephony/mbms/DownloadStatusListener` will be enqueued. If the middleware is not aware of the specified download request, this method will throw an `https://developer.android.com/reference/java/lang/IllegalArgumentException`. If the operation encountered an error, the error code will be delivered via `https://developer.android.com/reference/android/telephony/mbms/MbmsDownloadSessionCallback#onError(int,%20java.lang.String)`. Repeated calls to this method for the same `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest` will replace the previously registered listener.

<br />

| Parameters ||
|---|---|
| `request` | `DownloadRequest`: The `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest` that you want updates on. This value cannot be `null`. <br /> |
| `executor` | `Executor`: The `https://developer.android.com/reference/java/util/concurrent/Executor` on which calls to `listener ` should be executed. This value cannot be `null`. <br /> |
| `listener` | `DownloadStatusListener`: The listener that should be called when the middleware has information to share on the status download. This value cannot be `null`. <br /> |

### cancelDownload

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void cancelDownload (DownloadRequest downloadRequest)
```

Attempts to cancel the specified `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest`. If the operation encountered an error, the error code will be delivered via `https://developer.android.com/reference/android/telephony/mbms/MbmsDownloadSessionCallback#onError(int,%20java.lang.String)`.

<br />

| Parameters ||
|---|---|
| `downloadRequest` | `DownloadRequest`: The download request that you wish to cancel. This value cannot be `null`. <br /> |

### close

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void close ()
```

Terminates this instance. After this method returns, no further callbacks originating from the middleware will be enqueued on the provided instance of `https://developer.android.com/reference/android/telephony/mbms/MbmsDownloadSessionCallback`, but callbacks that have already been enqueued will still be delivered. It is safe to call `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#create(android.content.Context,%20java.util.concurrent.Executor,%20int,%20android.telephony.mbms.MbmsDownloadSessionCallback)` to obtain another instance of `https://developer.android.com/reference/android/telephony/MbmsDownloadSession` immediately after this method returns. May throw an `https://developer.android.com/reference/java/lang/IllegalStateException`

<br />

### create

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static MbmsDownloadSession create (Context context, 
                Executor executor, 
                int subscriptionId, 
                MbmsDownloadSessionCallback callback)
```

Create a new MbmsDownloadManager using the given subscription ID. Note that this call will bind a remote service and that may take a bit. The instance of `https://developer.android.com/reference/android/telephony/MbmsDownloadSession` that is returned will not be ready for use until `https://developer.android.com/reference/android/telephony/mbms/MbmsDownloadSessionCallback#onMiddlewareReady()` is called on the provided callback. If you attempt to use the instance before it is ready, an `https://developer.android.com/reference/java/lang/IllegalStateException` will be thrown or an error will be delivered through `https://developer.android.com/reference/android/telephony/mbms/MbmsDownloadSessionCallback#onError(int,%20java.lang.String)`. This also may throw an `https://developer.android.com/reference/java/lang/IllegalArgumentException`. You may only have one instance of `https://developer.android.com/reference/android/telephony/MbmsDownloadSession` per UID. If you call this method while there is an active instance of `https://developer.android.com/reference/android/telephony/MbmsDownloadSession` in your process (in other words, one that has not had `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#close()` called on it), this method will throw an `https://developer.android.com/reference/java/lang/IllegalStateException`. If you call this method in a different process running under the same UID, an error will be indicated via `https://developer.android.com/reference/android/telephony/mbms/MbmsDownloadSessionCallback#onError(int,%20java.lang.String)`. Note that initialization may fail asynchronously. If you wish to try again after you receive such an asynchronous error, you must call `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#close()` on the instance of `https://developer.android.com/reference/android/telephony/MbmsDownloadSession` that you received before calling this method again.

<br />

| Parameters ||
|---|---|
| `context` | `Context`: The instance of `https://developer.android.com/reference/android/content/Context` to use. This value cannot be `null`. <br /> |
| `executor` | `Executor`: The executor on which you wish to execute callbacks. This value cannot be `null`. <br /> |
| `subscriptionId` | `int`: The data subscription ID to use <br /> |
| `callback` | `MbmsDownloadSessionCallback`: A callback to get asynchronous error messages and file service updates. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/telephony/MbmsDownloadSession` | A new instance of `https://developer.android.com/reference/android/telephony/MbmsDownloadSession`, or null if an error occurred during setup. <br /> |

### create

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static MbmsDownloadSession create (Context context, 
                Executor executor, 
                MbmsDownloadSessionCallback callback)
```

Create a new `https://developer.android.com/reference/android/telephony/MbmsDownloadSession` using the system default data subscription ID. See `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#create(android.content.Context,%20java.util.concurrent.Executor,%20int,%20android.telephony.mbms.MbmsDownloadSessionCallback)`

<br />

| Parameters ||
|---|---|
| `context` | `Context`: This value cannot be `null`. <br /> |
| `executor` | `Executor`: This value cannot be `null`. <br /> |
| `callback` | `MbmsDownloadSessionCallback`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/telephony/MbmsDownloadSession` | <br /> |

### download

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void download (DownloadRequest request)
```

Requests the download of a file or set of files that the carrier has indicated to be available. May throw an `https://developer.android.com/reference/java/lang/IllegalArgumentException` If `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#setTempFileRootDirectory(java.io.File)` has not called after the app has been installed, this method will create a directory at the default location defined at `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#DEFAULT_TOP_LEVEL_TEMP_DIRECTORY` and store that as the temp file root directory. If the `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest` has a destination that is not on the same filesystem as the temp file directory provided via `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#getTempFileRootDirectory()`, an `https://developer.android.com/reference/java/lang/IllegalArgumentException` will be thrown. Asynchronous errors through the callback may include any error not specific to the streaming use-case. If no error is delivered via the callback after calling this method, that means that the middleware has successfully started the download or scheduled the download, if the download is at a future time.

<br />

| Parameters ||
|---|---|
| `request` | `DownloadRequest`: The request that specifies what should be downloaded. This value cannot be `null`. <br /> |

### getMaximumServiceAnnouncementSize

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static int getMaximumServiceAnnouncementSize ()
```

Returns the maximum size of the service announcement descriptor that can be provided via `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#addServiceAnnouncement(byte[])`

<br />

| Returns ||
|---|---|
| `int` | The maximum length of the byte array passed as an argument to `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#addServiceAnnouncement(byte[])`. <br /> |

### getTempFileRootDirectory

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public File getTempFileRootDirectory ()
```

Retrieves the currently configured temp file root directory. Returns the file that was configured via `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#setTempFileRootDirectory(java.io.File)` or the default directory `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#download(android.telephony.mbms.DownloadRequest)` was called without ever setting the temp file root. If neither method has been called since the last time the app's shared preferences were reset, returns `null`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/io/File` | A `https://developer.android.com/reference/java/io/File` pointing to the configured temp file directory, or null if not yet configured. <br /> |

### listPendingDownloads

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public List<DownloadRequest> listPendingDownloads ()
```

Returns a list of pending `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest`s that originated from this application. A pending request is one that was issued via `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#download(android.telephony.mbms.DownloadRequest)` but not cancelled through `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#cancelDownload(android.telephony.mbms.DownloadRequest)`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/telephony/mbms/DownloadRequest>` | A list, possibly empty, of `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest`s. This value cannot be `null`. <br /> |

### removeProgressListener

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void removeProgressListener (DownloadRequest request, 
                DownloadProgressListener listener)
```

Un-register a listener previously registered via `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#addProgressListener(android.telephony.mbms.DownloadRequest,%20java.util.concurrent.Executor,%20android.telephony.mbms.DownloadProgressListener)`. After this method is called, no further callbacks will be enqueued on the `https://developer.android.com/reference/android/os/Handler` provided upon registration, even if this method throws an exception. If the middleware is not aware of the specified download request, this method will throw an `https://developer.android.com/reference/java/lang/IllegalArgumentException`. If the operation encountered an error, the error code will be delivered via `https://developer.android.com/reference/android/telephony/mbms/MbmsDownloadSessionCallback#onError(int,%20java.lang.String)`.

<br />

| Parameters ||
|---|---|
| `request` | `DownloadRequest`: The `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest` provided during registration. This value cannot be `null`. <br /> |
| `listener` | `DownloadProgressListener`: The listener provided during registration. This value cannot be `null`. <br /> |

### removeStatusListener

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void removeStatusListener (DownloadRequest request, 
                DownloadStatusListener listener)
```

Un-register a listener previously registered via `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#addStatusListener(android.telephony.mbms.DownloadRequest,%20java.util.concurrent.Executor,%20android.telephony.mbms.DownloadStatusListener)`. After this method is called, no further calls will be enqueued on the `https://developer.android.com/reference/java/util/concurrent/Executor` provided upon registration, even if this method throws an exception. If the middleware is not aware of the specified download request, this method will throw an `https://developer.android.com/reference/java/lang/IllegalArgumentException`. If the operation encountered an error, the error code will be delivered via `https://developer.android.com/reference/android/telephony/mbms/MbmsDownloadSessionCallback#onError(int,%20java.lang.String)`.

<br />

| Parameters ||
|---|---|
| `request` | `DownloadRequest`: The `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest` provided during registration. This value cannot be `null`. <br /> |
| `listener` | `DownloadStatusListener`: The listener provided during registration. This value cannot be `null`. <br /> |

### requestDownloadState

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void requestDownloadState (DownloadRequest downloadRequest, 
                FileInfo fileInfo)
```

Requests information about the state of a file pending download. The state will be delivered as a callback via `https://developer.android.com/reference/android/telephony/mbms/DownloadStatusListener#onStatusUpdated(android.telephony.mbms.DownloadRequest,%20android.telephony.mbms.FileInfo,%20int)`. If no such callback has been registered via `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#addProgressListener(android.telephony.mbms.DownloadRequest,%20java.util.concurrent.Executor,%20android.telephony.mbms.DownloadProgressListener)`, this method will be a no-op. If the middleware has no record of the file indicated by `fileInfo` being associated with `downloadRequest`, an `https://developer.android.com/reference/java/lang/IllegalArgumentException` will be thrown.

<br />

| Parameters ||
|---|---|
| `downloadRequest` | `DownloadRequest`: The download request to query. <br /> |
| `fileInfo` | `FileInfo`: The particular file within the request to get information on. <br /> |

### requestUpdateFileServices

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void requestUpdateFileServices (List<String> classList)
```

An inspection API to retrieve the list of available `https://developer.android.com/reference/android/telephony/mbms/FileServiceInfo`s currently being advertised. The results are returned asynchronously via a call to `https://developer.android.com/reference/android/telephony/mbms/MbmsDownloadSessionCallback#onFileServicesUpdated(java.util.List<android.telephony.mbms.FileServiceInfo>)` Asynchronous error codes via the `https://developer.android.com/reference/android/telephony/mbms/MbmsDownloadSessionCallback#onError(int,%20java.lang.String)` callback may include any of the errors that are not specific to the streaming use-case. May throw an `https://developer.android.com/reference/java/lang/IllegalStateException` or `https://developer.android.com/reference/java/lang/IllegalArgumentException`.

<br />

| Parameters ||
|---|---|
| `classList` | `List`: A list of service classes which the app wishes to receive `https://developer.android.com/reference/android/telephony/mbms/MbmsDownloadSessionCallback#onFileServicesUpdated(java.util.List<android.telephony.mbms.FileServiceInfo>)` callbacks about. Subsequent calls to this method will replace this list of service classes (i.e. the middleware will no longer send updates for services matching classes only in the old list). Values in this list should be negotiated with the wireless carrier prior to using this API. This value cannot be `null`. <br /> |

### resetDownloadKnowledge

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void resetDownloadKnowledge (DownloadRequest downloadRequest)
```

Resets the middleware's knowledge of previously-downloaded files in this download request. Normally, the middleware keeps track of the hashes of downloaded files and won't re-download files whose server-reported hash matches one of the already-downloaded files. This means that if the file is accidentally deleted by the user or by the app, the middleware will not try to download it again. This method will reset the middleware's cache of hashes for the provided `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest`, so that previously downloaded content will be downloaded again when available. This will not interrupt in-progress downloads. This is distinct from cancelling and re-issuing the download request -- if you cancel and re-issue, the middleware will not clear its cache of download state information. If the middleware is not aware of the specified download request, an `https://developer.android.com/reference/java/lang/IllegalArgumentException` will be thrown.

<br />

| Parameters ||
|---|---|
| `downloadRequest` | `DownloadRequest`: The request to re-download files for. <br /> |

### setTempFileRootDirectory

Added in [API level 28](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void setTempFileRootDirectory (File tempFileRootDirectory)
```

Sets the temp file root for downloads. All temp files created for the middleware to write to will be contained in the specified directory. Applications that wish to specify a location only need to call this method once as long their data is persisted in storage -- the argument will be stored both in a local instance of `https://developer.android.com/reference/android/content/SharedPreferences` and by the middleware. If this method is not called at least once before calling `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#download(android.telephony.mbms.DownloadRequest)`, the framework will default to a directory formed by the concatenation of the app's files directory and `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#DEFAULT_TOP_LEVEL_TEMP_DIRECTORY`. Before calling this method, the app must cancel all of its pending `https://developer.android.com/reference/android/telephony/mbms/DownloadRequest`s via `https://developer.android.com/reference/android/telephony/MbmsDownloadSession#cancelDownload(android.telephony.mbms.DownloadRequest)`. If this is not done, you will receive an asynchronous error with code `https://developer.android.com/reference/android/telephony/mbms/MbmsErrors.DownloadErrors#ERROR_CANNOT_CHANGE_TEMP_FILE_ROOT` unless the provided directory is the same as what has been previously configured. The `https://developer.android.com/reference/java/io/File` supplied as a root temp file directory must already exist. If not, an `https://developer.android.com/reference/java/lang/IllegalArgumentException` will be thrown. In addition, as an additional correctness check, an `https://developer.android.com/reference/java/lang/IllegalArgumentException` will be thrown if you attempt to set the temp file root directory to one of your data roots (the value of `https://developer.android.com/reference/android/content/Context#getDataDir()`, `https://developer.android.com/reference/android/content/Context#getFilesDir()`, or `https://developer.android.com/reference/android/content/Context#getCacheDir()`).

<br />

| Parameters ||
|---|---|
| `tempFileRootDirectory` | `File`: A directory to place temp files in. This value cannot be `null`. <br /> |