# DownloadRequest.Builder

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

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/telephony/mbms/DownloadRequest.Builder "View this page in Java")  

```
class Builder
```

|---|--------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                   ||
| ↳ | [android.telephony.mbms.DownloadRequest.Builder](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest.Builder#) |

## Summary

|                                                                                                                                                                                 Public constructors                                                                                                                                                                                  ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest.Builder#Builder(android.net.Uri,%20android.net.Uri))`(`sourceUri:` `[Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#)`, `destinationUri:` `[Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#)`)` Builds a new DownloadRequest. |

|                                                                                                                                                                                                                                                                                                                                   Public methods                                                                                                                                                                                                                                                                                                                                   ||
|--------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[DownloadRequest](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest)!                        | [build](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest.Builder#build())`()` <br />                                                                                                                                                                                                                                                                                                                                                                                                                    |
| openstatic[DownloadRequest.Builder](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest.Builder#)! | [fromDownloadRequest](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest.Builder#fromDownloadRequest(android.telephony.mbms.DownloadRequest))`(`other:` `[DownloadRequest](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest)!`)` Constructs a[Builder](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest.Builder#)from a[DownloadRequest](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest) |
| openstatic[DownloadRequest.Builder](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest.Builder#)! | [fromSerializedRequest](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest.Builder#fromSerializedRequest(kotlin.ByteArray))`(`data:` `[ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)!`)` This method constructs a new instance of[Builder](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest.Builder#)based on the serialized data passed in.                                                                                |
| open[DownloadRequest.Builder](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest.Builder#)!       | [setAppIntent](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest.Builder#setAppIntent(android.content.Intent))`(`intent:` `[Intent](https://developer.android.com/reference/kotlin/android/content/Intent.html#)!`)` Set the[Intent](https://developer.android.com/reference/kotlin/android/content/Intent.html#)that should be sent when the download completes or fails.                                                                                                                               |
| open[DownloadRequest.Builder](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest.Builder#)!       | [setServiceInfo](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest.Builder#setServiceInfo(android.telephony.mbms.FileServiceInfo))`(`serviceInfo:` `[FileServiceInfo](https://developer.android.com/reference/kotlin/android/telephony/mbms/FileServiceInfo)!`)` Sets the service from which the download request to be built will download from.                                                                                                                                                        |
| open[DownloadRequest.Builder](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest.Builder#)!       | [setSubscriptionId](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest.Builder#setSubscriptionId(kotlin.Int))`(`subscriptionId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Set the subscription ID on which the file(s) should be downloaded.                                                                                                                                                                                                                        |

## Public constructors

### Builder

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

```
Builder(
    sourceUri: Uri, 
    destinationUri: Uri)
```

Builds a new DownloadRequest.

|                                                                                                                                                                                                                                                                                                                               Parameters                                                                                                                                                                                                                                                                                                                                ||
|------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `sourceUri`      | [Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#):the source URI for the DownloadRequest to be built. This URI should never be null.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `destinationUri` | [Uri](https://developer.android.com/reference/kotlin/android/net/Uri.html#):The final location for the file(s) that are to be downloaded. It must be on the same filesystem as the temp file directory set via[android.telephony.MbmsDownloadSession#setTempFileRootDirectory(File)](https://developer.android.com/reference/kotlin/android/telephony/MbmsDownloadSession.html#setTempFileRootDirectory(java.io.File)). The provided path must be a directory that exists. An[IllegalArgumentException](https://developer.android.com/reference/kotlin/java/lang/IllegalArgumentException.html#)will be thrown otherwise. This value cannot be`null`. |

## Public methods

### build

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

```
open fun build(): DownloadRequest!
```  

### fromDownloadRequest

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

```
open static fun fromDownloadRequest(other: DownloadRequest!): DownloadRequest.Builder!
```

Constructs a[Builder](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest.Builder#)from a[DownloadRequest](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest)

|                                                                                                                                                                                   Parameters                                                                                                                                                                                   ||
|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `other` | [DownloadRequest](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest)!:The[DownloadRequest](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest)from which the data for the[Builder](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest.Builder#)should come. |

|                                                                                                                                                                                                Return                                                                                                                                                                                                 ||
|----------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DownloadRequest.Builder](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest.Builder#)! | An instance of[Builder](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest.Builder#)pre-populated with data from the provided[DownloadRequest](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest). |

### fromSerializedRequest

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

```
open static fun fromSerializedRequest(data: ByteArray!): DownloadRequest.Builder!
```

This method constructs a new instance of[Builder](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest.Builder#)based on the serialized data passed in.

|                                                                                                                                                     Parameters                                                                                                                                                      ||
|--------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `data` | [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)!:A byte array, the contents of which should have been originally obtained from[DownloadRequest.toByteArray()](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest#toByteArray()). |

### setAppIntent

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

```
open fun setAppIntent(intent: Intent!): DownloadRequest.Builder!
```

Set the[Intent](https://developer.android.com/reference/kotlin/android/content/Intent.html#)that should be sent when the download completes or fails. This should be an intent with a explicit[android.content.ComponentName](https://developer.android.com/reference/kotlin/android/content/ComponentName.html#)targeted to a[android.content.BroadcastReceiver](https://developer.android.com/reference/kotlin/android/content/BroadcastReceiver.html#)in the app's package. The middleware should not use this method.

|                                            Parameters                                             ||
|----------|-----------------------------------------------------------------------------------------|
| `intent` | [Intent](https://developer.android.com/reference/kotlin/android/content/Intent.html#)!: |

### setServiceInfo

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

```
open fun setServiceInfo(serviceInfo: FileServiceInfo!): DownloadRequest.Builder!
```

Sets the service from which the download request to be built will download from.

|                                                        Parameters                                                         ||
|---------------|------------------------------------------------------------------------------------------------------------|
| `serviceInfo` | [FileServiceInfo](https://developer.android.com/reference/kotlin/android/telephony/mbms/FileServiceInfo)!: |

|                                                            Return                                                             ||
|----------------------------------------------------------------------------------------------------------------------------|---|
| [DownloadRequest.Builder](https://developer.android.com/reference/kotlin/android/telephony/mbms/DownloadRequest.Builder#)! |   |

### setSubscriptionId

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

```
open fun setSubscriptionId(subscriptionId: Int): DownloadRequest.Builder!
```

Set the subscription ID on which the file(s) should be downloaded.

|                                          Parameters                                           ||
|------------------|-----------------------------------------------------------------------------|
| `subscriptionId` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): |