# NetworkRequest.Builder

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

# Builder

*** ** * ** ***

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

```
open class Builder
```

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

Builder used to create[NetworkRequest](https://developer.android.com/reference/kotlin/android/net/NetworkRequest)objects. Specify the Network features needed in terms of[NetworkCapabilities](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities)features

## Summary

|                                                                                                                                                Public constructors                                                                                                                                                 ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#Builder())`()` Default constructor for Builder.                                                                                                                                                                     |
| [Builder](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#Builder(android.net.NetworkRequest))`(`request:` `[NetworkRequest](https://developer.android.com/reference/kotlin/android/net/NetworkRequest)`)` Creates a new Builder of NetworkRequest from an existing instance. |

|                                                                                                                                                                                                                                                    Public methods                                                                                                                                                                                                                                                     ||
|-------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[NetworkRequest.Builder](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#)! | [addCapability](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#addCapability(kotlin.Int))`(`capability:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Add the given capability requirement to this builder.                                                                                                                   |
| open[NetworkRequest.Builder](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#)! | [addTransportType](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#addTransportType(kotlin.Int))`(`transportType:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Adds the given transport requirement to this builder.                                                                                                          |
| open[NetworkRequest](https://developer.android.com/reference/kotlin/android/net/NetworkRequest)!                  | [build](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#build())`()` Build[NetworkRequest](https://developer.android.com/reference/kotlin/android/net/NetworkRequest)give the current set of capabilities.                                                                                                                                                       |
| open[NetworkRequest.Builder](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#)  | [clearCapabilities](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#clearCapabilities())`()` Completely clears all the`NetworkCapabilities`from this builder instance, removing even the capabilities that are set by default when the object is constructed.                                                                                                    |
| open[NetworkRequest.Builder](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#)! | [removeCapability](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#removeCapability(kotlin.Int))`(`capability:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Removes (if found) the given capability from this builder instance.                                                                                               |
| open[NetworkRequest.Builder](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#)! | [removeTransportType](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#removeTransportType(kotlin.Int))`(`transportType:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Removes (if found) the given transport from this builder instance.                                                                                       |
| open[NetworkRequest.Builder](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#)  | [setIncludeOtherUidNetworks](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#setIncludeOtherUidNetworks(kotlin.Boolean))`(`include:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Specifies whether the built request should also match networks that do not apply to the calling UID.                                 |
| open[NetworkRequest.Builder](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#)! | [setNetworkSpecifier](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#setNetworkSpecifier(android.net.NetworkSpecifier))`(`networkSpecifier:` `[NetworkSpecifier](https://developer.android.com/reference/kotlin/android/net/NetworkSpecifier)!`)` Sets the optional bearer specific network specifier.                                                          |
| open[NetworkRequest.Builder](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#)! | [setNetworkSpecifier](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#setNetworkSpecifier(kotlin.String))`(`networkSpecifier:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` Sets the optional bearer specific network specifier.                                                                                        |
| open[NetworkRequest.Builder](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#)  | [setSubscriptionIds](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#setSubscriptionIds(kotlin.collections.MutableSet))`(`subIds:` `[MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)<[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)!>`)` Sets the optional subscription ID set. |

## Public constructors

### Builder

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

```
Builder()
```

Default constructor for Builder.  

### Builder

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

```
Builder(request: NetworkRequest)
```

Creates a new Builder of NetworkRequest from an existing instance.

|                                                             Parameters                                                             ||
|-----------|-------------------------------------------------------------------------------------------------------------------------|
| `request` | [NetworkRequest](https://developer.android.com/reference/kotlin/android/net/NetworkRequest):This value cannot be`null`. |

## Public methods

### addCapability

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

```
open fun addCapability(capability: Int): NetworkRequest.Builder!
```

Add the given capability requirement to this builder. These represent the requested network's required capabilities. Note that when searching for a network to satisfy a request, all capabilities requested must be satisfied.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         ||
|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `capability` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The capability to add. Value is[android.net.NetworkCapabilities#NET_CAPABILITY_MMS](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_MMS:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_SUPL](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_SUPL:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_DUN](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_DUN:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_FOTA](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_FOTA:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_IMS](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_IMS:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_CBS](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_CBS:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_WIFI_P2P](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_WIFI_P2P:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_IA](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_IA:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_RCS](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_RCS:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_XCAP](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_XCAP:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_EIMS](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_EIMS:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_NOT_METERED](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_METERED:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_INTERNET](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_INTERNET:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_NOT_RESTRICTED](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_RESTRICTED:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_TRUSTED](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_TRUSTED:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_NOT_VPN](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_VPN:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_VALIDATED](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_VALIDATED:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_CAPTIVE_PORTAL](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_CAPTIVE_PORTAL:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_NOT_ROAMING](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_ROAMING:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_FOREGROUND](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_FOREGROUND:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_NOT_CONGESTED](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_CONGESTED:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_NOT_SUSPENDED](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_SUSPENDED:kotlin.Int), android.net.NetworkCapabilities.NET_CAPABILITY_OEM_PAID,[android.net.NetworkCapabilities#NET_CAPABILITY_MCX](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_MCX:kotlin.Int), android.net.NetworkCapabilities.NET_CAPABILITY_PARTIAL_CONNECTIVITY,[android.net.NetworkCapabilities#NET_CAPABILITY_TEMPORARILY_NOT_METERED](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_TEMPORARILY_NOT_METERED:kotlin.Int), android.net.NetworkCapabilities.NET_CAPABILITY_OEM_PRIVATE, android.net.NetworkCapabilities.NET_CAPABILITY_VEHICLE_INTERNAL, android.net.NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED,[android.net.NetworkCapabilities#NET_CAPABILITY_ENTERPRISE](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_ENTERPRISE:kotlin.Int), android.net.NetworkCapabilities.NET_CAPABILITY_VSIM, android.net.NetworkCapabilities.NET_CAPABILITY_BIP,[android.net.NetworkCapabilities#NET_CAPABILITY_HEAD_UNIT](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_HEAD_UNIT:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_MMTEL](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_MMTEL:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_PRIORITIZE_LATENCY](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_PRIORITIZE_LATENCY:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_PRIORITIZE_BANDWIDTH](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_PRIORITIZE_BANDWIDTH:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_LOCAL_NETWORK](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_LOCAL_NETWORK:kotlin.Int), or[android.net.NetworkCapabilities#NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED:kotlin.Int) |

|                                                                                             Return                                                                                              ||
|---------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|
| [NetworkRequest.Builder](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#)! | The builder to facilitate chaining`builder.addCapability(...).addCapability();`. |

### addTransportType

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

```
open fun addTransportType(transportType: Int): NetworkRequest.Builder!
```

Adds the given transport requirement to this builder. These represent the set of allowed transports for the request. Only networks using one of these transports will satisfy the request. If no particular transports are required, none should be specified here.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ||
|-----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `transportType` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The transport type to add. Value is[android.net.NetworkCapabilities#TRANSPORT_CELLULAR](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#TRANSPORT_CELLULAR:kotlin.Int),[android.net.NetworkCapabilities#TRANSPORT_WIFI](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#TRANSPORT_WIFI:kotlin.Int),[android.net.NetworkCapabilities#TRANSPORT_BLUETOOTH](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#TRANSPORT_BLUETOOTH:kotlin.Int),[android.net.NetworkCapabilities#TRANSPORT_ETHERNET](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#TRANSPORT_ETHERNET:kotlin.Int),[android.net.NetworkCapabilities#TRANSPORT_VPN](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#TRANSPORT_VPN:kotlin.Int),[android.net.NetworkCapabilities#TRANSPORT_WIFI_AWARE](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#TRANSPORT_WIFI_AWARE:kotlin.Int),[android.net.NetworkCapabilities#TRANSPORT_LOWPAN](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#TRANSPORT_LOWPAN:kotlin.Int), android.net.NetworkCapabilities.TRANSPORT_TEST,[android.net.NetworkCapabilities#TRANSPORT_USB](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#TRANSPORT_USB:kotlin.Int),[android.net.NetworkCapabilities#TRANSPORT_THREAD](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#TRANSPORT_THREAD:kotlin.Int), or[android.net.NetworkCapabilities#TRANSPORT_SATELLITE](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#TRANSPORT_SATELLITE:kotlin.Int) |

|                                                                       Return                                                                       ||
|---------------------------------------------------------------------------------------------------------------|-------------------------------------|
| [NetworkRequest.Builder](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#)! | The builder to facilitate chaining. |

### build

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

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

Build[NetworkRequest](https://developer.android.com/reference/kotlin/android/net/NetworkRequest)give the current set of capabilities.  

### clearCapabilities

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

```
open fun clearCapabilities(): NetworkRequest.Builder
```

Completely clears all the`NetworkCapabilities`from this builder instance, removing even the capabilities that are set by default when the object is constructed. Also removes any set forbidden capabilities.

|                                                                                    Return                                                                                     ||
|--------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------|
| [NetworkRequest.Builder](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#) | The builder to facilitate chaining. This value cannot be`null`. |

### removeCapability

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

```
open fun removeCapability(capability: Int): NetworkRequest.Builder!
```

Removes (if found) the given capability from this builder instance.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ||
|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `capability` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The capability to remove. Value is[android.net.NetworkCapabilities#NET_CAPABILITY_MMS](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_MMS:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_SUPL](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_SUPL:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_DUN](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_DUN:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_FOTA](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_FOTA:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_IMS](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_IMS:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_CBS](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_CBS:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_WIFI_P2P](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_WIFI_P2P:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_IA](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_IA:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_RCS](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_RCS:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_XCAP](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_XCAP:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_EIMS](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_EIMS:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_NOT_METERED](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_METERED:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_INTERNET](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_INTERNET:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_NOT_RESTRICTED](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_RESTRICTED:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_TRUSTED](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_TRUSTED:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_NOT_VPN](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_VPN:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_VALIDATED](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_VALIDATED:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_CAPTIVE_PORTAL](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_CAPTIVE_PORTAL:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_NOT_ROAMING](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_ROAMING:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_FOREGROUND](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_FOREGROUND:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_NOT_CONGESTED](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_CONGESTED:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_NOT_SUSPENDED](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_SUSPENDED:kotlin.Int), android.net.NetworkCapabilities.NET_CAPABILITY_OEM_PAID,[android.net.NetworkCapabilities#NET_CAPABILITY_MCX](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_MCX:kotlin.Int), android.net.NetworkCapabilities.NET_CAPABILITY_PARTIAL_CONNECTIVITY,[android.net.NetworkCapabilities#NET_CAPABILITY_TEMPORARILY_NOT_METERED](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_TEMPORARILY_NOT_METERED:kotlin.Int), android.net.NetworkCapabilities.NET_CAPABILITY_OEM_PRIVATE, android.net.NetworkCapabilities.NET_CAPABILITY_VEHICLE_INTERNAL, android.net.NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED,[android.net.NetworkCapabilities#NET_CAPABILITY_ENTERPRISE](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_ENTERPRISE:kotlin.Int), android.net.NetworkCapabilities.NET_CAPABILITY_VSIM, android.net.NetworkCapabilities.NET_CAPABILITY_BIP,[android.net.NetworkCapabilities#NET_CAPABILITY_HEAD_UNIT](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_HEAD_UNIT:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_MMTEL](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_MMTEL:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_PRIORITIZE_LATENCY](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_PRIORITIZE_LATENCY:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_PRIORITIZE_BANDWIDTH](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_PRIORITIZE_BANDWIDTH:kotlin.Int),[android.net.NetworkCapabilities#NET_CAPABILITY_LOCAL_NETWORK](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_LOCAL_NETWORK:kotlin.Int), or[android.net.NetworkCapabilities#NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED:kotlin.Int) |

|                                                                       Return                                                                       ||
|---------------------------------------------------------------------------------------------------------------|-------------------------------------|
| [NetworkRequest.Builder](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#)! | The builder to facilitate chaining. |

### removeTransportType

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

```
open fun removeTransportType(transportType: Int): NetworkRequest.Builder!
```

Removes (if found) the given transport from this builder instance.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       ||
|-----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `transportType` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The transport type to remove. Value is[android.net.NetworkCapabilities#TRANSPORT_CELLULAR](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#TRANSPORT_CELLULAR:kotlin.Int),[android.net.NetworkCapabilities#TRANSPORT_WIFI](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#TRANSPORT_WIFI:kotlin.Int),[android.net.NetworkCapabilities#TRANSPORT_BLUETOOTH](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#TRANSPORT_BLUETOOTH:kotlin.Int),[android.net.NetworkCapabilities#TRANSPORT_ETHERNET](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#TRANSPORT_ETHERNET:kotlin.Int),[android.net.NetworkCapabilities#TRANSPORT_VPN](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#TRANSPORT_VPN:kotlin.Int),[android.net.NetworkCapabilities#TRANSPORT_WIFI_AWARE](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#TRANSPORT_WIFI_AWARE:kotlin.Int),[android.net.NetworkCapabilities#TRANSPORT_LOWPAN](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#TRANSPORT_LOWPAN:kotlin.Int), android.net.NetworkCapabilities.TRANSPORT_TEST,[android.net.NetworkCapabilities#TRANSPORT_USB](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#TRANSPORT_USB:kotlin.Int),[android.net.NetworkCapabilities#TRANSPORT_THREAD](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#TRANSPORT_THREAD:kotlin.Int), or[android.net.NetworkCapabilities#TRANSPORT_SATELLITE](https://developer.android.com/reference/kotlin/android/net/NetworkCapabilities#TRANSPORT_SATELLITE:kotlin.Int) |

|                                                                       Return                                                                       ||
|---------------------------------------------------------------------------------------------------------------|-------------------------------------|
| [NetworkRequest.Builder](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#)! | The builder to facilitate chaining. |

### setIncludeOtherUidNetworks

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

```
open fun setIncludeOtherUidNetworks(include: Boolean): NetworkRequest.Builder
```

Specifies whether the built request should also match networks that do not apply to the calling UID. By default, the built request will only match networks that apply to the calling UID. If this method is called with`true`, the built request will match any network on the system that matches the other parameters of the request. In this case, any information in the built request that is subject to redaction for security or privacy purposes, such as a[NetworkSpecifier](https://developer.android.com/reference/kotlin/android/net/NetworkSpecifier), will be redacted or removed to prevent the application deducing sensitive information.

|                                                                          Parameters                                                                           ||
|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------|
| `include` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):Whether to match networks that do not apply to the calling UID. |

|                                                                                    Return                                                                                     ||
|--------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------|
| [NetworkRequest.Builder](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#) | The builder to facilitate chaining. This value cannot be`null`. |

### setNetworkSpecifier

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

```
open fun setNetworkSpecifier(networkSpecifier: NetworkSpecifier!): NetworkRequest.Builder!
```

Sets the optional bearer specific network specifier. This has no meaning if a single transport is also not specified, so calling this without a single transport set will generate an exception, as will subsequently adding or removing transports after this is set.

<br />

|                                                                                         Parameters                                                                                         ||
|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `networkSpecifier` | [NetworkSpecifier](https://developer.android.com/reference/kotlin/android/net/NetworkSpecifier)!:A concrete, parcelable framework class that extends NetworkSpecifier. |

### setNetworkSpecifier

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

```
open fun setNetworkSpecifier(networkSpecifier: String!): NetworkRequest.Builder!
```

**Deprecated:** *Use[setNetworkSpecifier(android.net.NetworkSpecifier)](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#setNetworkSpecifier(android.net.NetworkSpecifier))instead.*

Sets the optional bearer specific network specifier. This has no meaning if a single transport is also not specified, so calling this without a single transport set will generate an exception, as will subsequently adding or removing transports after this is set.

<br />

If the`networkSpecifier`is provided, it shall be interpreted as follows:

- If the specifier can be parsed as an integer, it will be treated as a[TelephonyNetworkSpecifier](https://developer.android.com/reference/kotlin/android/net/package-summary), and the provided integer will be interpreted as a SubscriptionId.
- If the value is an ethernet interface name, it will be treated as such.
- For all other cases, the behavior is undefined.

|                                                                                                            Parameters                                                                                                            ||
|--------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `networkSpecifier` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!:A`String`of either a SubscriptionId in cellular network request or an ethernet interface name in ethernet network request. |

### setSubscriptionIds

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[U Extensions 12](https://developer.android.com/sdkExtensions)  

```
open fun setSubscriptionIds(subIds: MutableSet<Int!>): NetworkRequest.Builder
```

Sets the optional subscription ID set.

This specify the subscription IDs requirement. A network will satisfy this request only if it matches one of the subIds in this set. An empty set matches all networks, including those without a subId.

Registering a NetworkRequest with a non-empty set of subIds requires the NETWORK_FACTORY permission.

|                                                                                                                             Parameters                                                                                                                             ||
|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `subIds` | [MutableSet](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index.html)\<[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)!\>:A`Set`that represents subscription IDs. This value cannot be`null`. |

|                                                                  Return                                                                   ||
|--------------------------------------------------------------------------------------------------------------|-----------------------------|
| [NetworkRequest.Builder](https://developer.android.com/reference/kotlin/android/net/NetworkRequest.Builder#) | This value cannot be`null`. |