# VcnConfig.Builder

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/android/net/vcn/VcnConfig.Builder#pubctors)\|[Methods](https://developer.android.com/reference/android/net/vcn/VcnConfig.Builder#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/net/vcn/VcnConfig.Builder#inhmethods)  

# VcnConfig.Builder

*** ** * ** ***

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

`
public
static
final

class
VcnConfig.Builder
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|-----------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.net.vcn.VcnConfig.Builder |

<br />

*** ** * ** ***

This class is used to incrementally build[VcnConfig](https://developer.android.com/reference/android/net/vcn/VcnConfig)objects.

## Summary

|                                                                                               ### Public constructors                                                                                                ||
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[Builder](https://developer.android.com/reference/android/net/vcn/VcnConfig.Builder#Builder(android.content.Context))`(`[Context](https://developer.android.com/reference/android/content/Context)` context) ` |

|                                                                                                                                                                                                                                                ### Public methods                                                                                                                                                                                                                                                ||
|---------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[VcnConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnConfig.Builder) | ` `[addGatewayConnectionConfig](https://developer.android.com/reference/android/net/vcn/VcnConfig.Builder#addGatewayConnectionConfig(android.net.vcn.VcnGatewayConnectionConfig))`(`[VcnGatewayConnectionConfig](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig)` gatewayConnectionConfig) ` Adds a configuration for an individual gateway connection.                   |
| ` `[VcnConfig](https://developer.android.com/reference/android/net/vcn/VcnConfig)                 | ` `[build](https://developer.android.com/reference/android/net/vcn/VcnConfig.Builder#build())`() ` Builds and validates the VcnConfig.                                                                                                                                                                                                                                                                        |
| ` `[VcnConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnConfig.Builder) | ` `[setRestrictedUnderlyingNetworkTransports](https://developer.android.com/reference/android/net/vcn/VcnConfig.Builder#setRestrictedUnderlyingNetworkTransports(java.util.Set<java.lang.Integer>))`(`[Set](https://developer.android.com/reference/java/util/Set)`<`[Integer](https://developer.android.com/reference/java/lang/Integer)`> transports) ` Sets transports that will be restricted by the VCN. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public constructors

### Builder

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

```
public Builder (Context context)
```

<br />

<br />

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

## Public methods

### addGatewayConnectionConfig

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

```
public VcnConfig.Builder addGatewayConnectionConfig (VcnGatewayConnectionConfig gatewayConnectionConfig)
```

Adds a configuration for an individual gateway connection.

<br />

|                                                                     Parameters                                                                     ||
|---------------------------|-------------------------------------------------------------------------------------------------------------------------|
| `gatewayConnectionConfig` | `VcnGatewayConnectionConfig`: the configuration for an individual gateway connection This value cannot be`null`. <br /> |

|                                                                                                                      Returns                                                                                                                      ||
|------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| [VcnConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnConfig.Builder) | this[Builder](https://developer.android.com/reference/android/net/vcn/VcnConfig.Builder)instance, for chaining This value cannot be`null`. <br /> |

|                                                                                                                                                                                                                                      Throws                                                                                                                                                                                                                                      ||
|--------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if a VcnGatewayConnectionConfig has already been set for this[VcnConfig](https://developer.android.com/reference/android/net/vcn/VcnConfig)with the same GatewayConnection name (as returned via[VcnGatewayConnectionConfig.getGatewayConnectionName()](https://developer.android.com/reference/android/net/vcn/VcnGatewayConnectionConfig#getGatewayConnectionName())). |

### build

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

```
public VcnConfig build ()
```

Builds and validates the VcnConfig.

<br />

|                                                                      Returns                                                                       ||
|--------------------------------------------------------------------------------|--------------------------------------------------------------------|
| [VcnConfig](https://developer.android.com/reference/android/net/vcn/VcnConfig) | an immutable VcnConfig instance This value cannot be`null`. <br /> |

### setRestrictedUnderlyingNetworkTransports

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

```
public VcnConfig.Builder setRestrictedUnderlyingNetworkTransports (Set<Integer> transports)
```

Sets transports that will be restricted by the VCN.

In general, apps will not be able to bind to, or use a restricted network. In other words, unless the network type is marked restricted, any app can opt to use underlying networks, instead of through the VCN.

<br />

|                                                                                                                                                                Parameters                                                                                                                                                                ||
|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `transports` | `Set`: transports that will be restricted by VCN. Networks that include any of the transports will be marked as restricted.[NetworkCapabilities.TRANSPORT_WIFI](https://developer.android.com/reference/android/net/NetworkCapabilities#TRANSPORT_WIFI)is marked restricted by default. This value cannot be`null`. <br /> |

|                                                                                                                      Returns                                                                                                                      ||
|------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| [VcnConfig.Builder](https://developer.android.com/reference/android/net/vcn/VcnConfig.Builder) | this[Builder](https://developer.android.com/reference/android/net/vcn/VcnConfig.Builder)instance, for chaining This value cannot be`null`. <br /> |

|                                                                           Throws                                                                           ||
|--------------------------------------------------------------------------------------------------------|----------------------------------------------------|
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException) | if the input contains unsupported transport types. |

**See also:**

- [NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED](https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_RESTRICTED)