# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Ctors | Methods | Inherited Methods

# NetworkRequest.Builder

`public static class NetworkRequest.Builder`
`extends Object` ``

java.lang.Object
↳ | android.net.NetworkRequest.Builder

Builder used to create `NetworkRequest` objects. Specify the Network features needed in terms of `NetworkCapabilities` features

## Summary

### Public constructors
`Builder()` Default constructor for Builder.

### Public methods
`NetworkRequest.Builder` | `addCapability(int capability)` Add the given capability requirement to this builder.
`NetworkRequest.Builder` | `addTransportType(int transportType)` Adds the given transport requirement to this builder.
`NetworkRequest` | `build()` Build `NetworkRequest` give the current set of capabilities.
`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.
`NetworkRequest.Builder` | `removeCapability(int capability)` Removes (if found) the given capability from this builder instance.
`NetworkRequest.Builder` | `removeTransportType(int transportType)` Removes (if found) the given transport from this builder instance.
`NetworkRequest.Builder` | `setNetworkSpecifier(NetworkSpecifier networkSpecifier)` Sets the optional bearer specific network specifier.
`NetworkRequest.Builder` | `setNetworkSpecifier(String networkSpecifier)` This method is deprecated. Use `setNetworkSpecifier(android.net.NetworkSpecifier)` instead.

### Inherited methods
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.

## Public constructors

### Builder

    public Builder ()

Default constructor for Builder.

## Public methods

### addCapability

    public NetworkRequest.Builder addCapability (int capability)

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`: The capability to add. Value is `NetworkCapabilities.NET_CAPABILITY_MMS`, `NetworkCapabilities.NET_CAPABILITY_SUPL`, `NetworkCapabilities.NET_CAPABILITY_DUN`, `NetworkCapabilities.NET_CAPABILITY_FOTA`, `NetworkCapabilities.NET_CAPABILITY_IMS`, `NetworkCapabilities.NET_CAPABILITY_CBS`, `NetworkCapabilities.NET_CAPABILITY_WIFI_P2P`, `NetworkCapabilities.NET_CAPABILITY_IA`, `NetworkCapabilities.NET_CAPABILITY_RCS`, `NetworkCapabilities.NET_CAPABILITY_XCAP`, `NetworkCapabilities.NET_CAPABILITY_EIMS`, `NetworkCapabilities.NET_CAPABILITY_NOT_METERED`, `NetworkCapabilities.NET_CAPABILITY_INTERNET`, `NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED`, `NetworkCapabilities.NET_CAPABILITY_TRUSTED`, `NetworkCapabilities.NET_CAPABILITY_NOT_VPN`, `NetworkCapabilities.NET_CAPABILITY_VALIDATED`, `NetworkCapabilities.NET_CAPABILITY_CAPTIVE_PORTAL`, `NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING`, `NetworkCapabilities.NET_CAPABILITY_FOREGROUND`, `NetworkCapabilities.NET_CAPABILITY_NOT_CONGESTED`, `NetworkCapabilities.NET_CAPABILITY_NOT_SUSPENDED`, android.net.NetworkCapabilities.NET_CAPABILITY_OEM_PAID, `NetworkCapabilities.NET_CAPABILITY_MCX`, android.net.NetworkCapabilities.NET_CAPABILITY_PARTIAL_CONNECTIVITY, or `NetworkCapabilities.NET_CAPABILITY_TEMPORARILY_NOT_METERED`

Returns
`NetworkRequest.Builder` | The builder to facilitate chaining `builder.addCapability(...).addCapability();`.

### addTransportType

    public NetworkRequest.Builder addTransportType (int transportType)

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`: The transport type to add. Value is `NetworkCapabilities.TRANSPORT_CELLULAR`, `NetworkCapabilities.TRANSPORT_WIFI`, `NetworkCapabilities.TRANSPORT_BLUETOOTH`, `NetworkCapabilities.TRANSPORT_ETHERNET`, `NetworkCapabilities.TRANSPORT_VPN`, `NetworkCapabilities.TRANSPORT_WIFI_AWARE`, `NetworkCapabilities.TRANSPORT_LOWPAN`, or android.net.NetworkCapabilities.TRANSPORT_TEST

Returns
`NetworkRequest.Builder` | The builder to facilitate chaining.

### build

    public NetworkRequest build ()

Build `NetworkRequest` give the current set of capabilities.

Returns
`NetworkRequest` |

### clearCapabilities

    public 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.

Returns
`NetworkRequest.Builder` | The builder to facilitate chaining. This value cannot be `null`.

### removeCapability

    public NetworkRequest.Builder removeCapability (int capability)

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

Parameters
`capability` | `int`: The capability to remove. Value is `NetworkCapabilities.NET_CAPABILITY_MMS`, `NetworkCapabilities.NET_CAPABILITY_SUPL`, `NetworkCapabilities.NET_CAPABILITY_DUN`, `NetworkCapabilities.NET_CAPABILITY_FOTA`, `NetworkCapabilities.NET_CAPABILITY_IMS`, `NetworkCapabilities.NET_CAPABILITY_CBS`, `NetworkCapabilities.NET_CAPABILITY_WIFI_P2P`, `NetworkCapabilities.NET_CAPABILITY_IA`, `NetworkCapabilities.NET_CAPABILITY_RCS`, `NetworkCapabilities.NET_CAPABILITY_XCAP`, `NetworkCapabilities.NET_CAPABILITY_EIMS`, `NetworkCapabilities.NET_CAPABILITY_NOT_METERED`, `NetworkCapabilities.NET_CAPABILITY_INTERNET`, `NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED`, `NetworkCapabilities.NET_CAPABILITY_TRUSTED`, `NetworkCapabilities.NET_CAPABILITY_NOT_VPN`, `NetworkCapabilities.NET_CAPABILITY_VALIDATED`, `NetworkCapabilities.NET_CAPABILITY_CAPTIVE_PORTAL`, `NetworkCapabilities.NET_CAPABILITY_NOT_ROAMING`, `NetworkCapabilities.NET_CAPABILITY_FOREGROUND`, `NetworkCapabilities.NET_CAPABILITY_NOT_CONGESTED`, `NetworkCapabilities.NET_CAPABILITY_NOT_SUSPENDED`, android.net.NetworkCapabilities.NET_CAPABILITY_OEM_PAID, `NetworkCapabilities.NET_CAPABILITY_MCX`, android.net.NetworkCapabilities.NET_CAPABILITY_PARTIAL_CONNECTIVITY, or `NetworkCapabilities.NET_CAPABILITY_TEMPORARILY_NOT_METERED`

Returns
`NetworkRequest.Builder` | The builder to facilitate chaining.

### removeTransportType

    public NetworkRequest.Builder removeTransportType (int transportType)

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

Parameters
`transportType` | `int`: The transport type to remove. Value is `NetworkCapabilities.TRANSPORT_CELLULAR`, `NetworkCapabilities.TRANSPORT_WIFI`, `NetworkCapabilities.TRANSPORT_BLUETOOTH`, `NetworkCapabilities.TRANSPORT_ETHERNET`, `NetworkCapabilities.TRANSPORT_VPN`, `NetworkCapabilities.TRANSPORT_WIFI_AWARE`, `NetworkCapabilities.TRANSPORT_LOWPAN`, or android.net.NetworkCapabilities.TRANSPORT_TEST

Returns
`NetworkRequest.Builder` | The builder to facilitate chaining.

### setNetworkSpecifier

    public NetworkRequest.Builder setNetworkSpecifier (NetworkSpecifier networkSpecifier)

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.

Parameters
`networkSpecifier` | `NetworkSpecifier`: A concrete, parcelable framework class that extends NetworkSpecifier.

Returns
`NetworkRequest.Builder` |

### setNetworkSpecifier

    public NetworkRequest.Builder setNetworkSpecifier (String networkSpecifier)

This method is deprecated.
Use `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.

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`, 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`: A `String` of either a SubscriptionId in cellular network request or an ethernet interface name in ethernet network request.

Returns
`NetworkRequest.Builder` |

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*