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

# Ikev2VpnProfile.Builder

*** ** * ** ***


`
public
static
final

class
Ikev2VpnProfile.Builder
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

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

<br />

*** ** * ** ***

A incremental builder for IKEv2 VPN profiles

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder#Builder(android.net.ipsec.ike.IkeTunnelConnectionParams)(https://developer.android.com/reference/android/net/ipsec/ike/IkeTunnelConnectionParams ikeTunConnParams) ` Creates a new builder from a `https://developer.android.com/reference/android/net/ipsec/ike/IkeTunnelConnectionParams` Requires the `https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_IPSEC_TUNNELS` feature which can be detected using `https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)`. |
| ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder#Builder(java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String serverAddr, https://developer.android.com/reference/java/lang/String identity) ` Creates a new builder with the basic parameters of an IKEv2/IPsec VPN. |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/net/Ikev2VpnProfile` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder#build()() ` Validates, builds and provisions the VpnProfile. |
| ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder#setAllowedAlgorithms(java.util.List<java.lang.String>)(https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/java/lang/String> algorithmNames) ` Sets the allowable set of IPsec algorithms If set, this will constrain the set of algorithms that the IPsec tunnel will use for integrity verification and encryption to the provided list. |
| ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder#setAuthDigitalSignature(java.security.cert.X509Certificate,%20java.security.PrivateKey,%20java.security.cert.X509Certificate)(https://developer.android.com/reference/java/security/cert/X509Certificate userCert, https://developer.android.com/reference/java/security/PrivateKey key, https://developer.android.com/reference/java/security/cert/X509Certificate serverRootCa) ` Set the IKEv2 authentication to use Digital Signature Authentication with the given key. |
| ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder#setAuthPsk(byte[])(byte[] psk) ` Set the IKEv2 authentication to use Preshared keys. |
| ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder#setAuthUsernamePassword(java.lang.String,%20java.lang.String,%20java.security.cert.X509Certificate)(https://developer.android.com/reference/java/lang/String user, https://developer.android.com/reference/java/lang/String pass, https://developer.android.com/reference/java/security/cert/X509Certificate serverRootCa) ` Set the IKEv2 authentication to use the provided username/password. |
| ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder#setAutomaticIpVersionSelectionEnabled(boolean)(boolean isEnabled) ` Sets the enabled state of the automatic IP version selection. |
| ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder#setAutomaticNattKeepaliveTimerEnabled(boolean)(boolean isEnabled) ` Sets the enabled state of the automatic NAT-T keepalive timers Note that if this builder was constructed with a `https://developer.android.com/reference/android/net/ipsec/ike/IkeTunnelConnectionParams`, but this is called with `true`, the framework will automatically choose the appropriate keepalive timer and ignore the settings in the session params embedded in the connection params. |
| ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder#setBypassable(boolean)(boolean isBypassable) ` Sets whether apps can bypass this VPN connection. |
| ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder#setLocalRoutesExcluded(boolean)(boolean excludeLocalRoutes) ` Sets whether the local traffic is exempted from the VPN. |
| ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder#setMaxMtu(int)(int mtu) ` Set the upper bound of the maximum transmission unit (MTU) of the VPN interface. |
| ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder#setMetered(boolean)(boolean isMetered) ` Marks the VPN network as metered. |
| ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder#setProxy(android.net.ProxyInfo)(https://developer.android.com/reference/android/net/ProxyInfo proxy) ` Sets a proxy for the VPN network. |
| ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | ` https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder#setRequiresInternetValidation(boolean)(boolean requiresInternetValidation) ` Request that this VPN undergoes Internet validation. |

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

## Public constructors

### Builder

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

```
public Builder (IkeTunnelConnectionParams ikeTunConnParams)
```

Creates a new builder from a `https://developer.android.com/reference/android/net/ipsec/ike/IkeTunnelConnectionParams`


Requires the `https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_IPSEC_TUNNELS` feature which can be detected using `https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)`.

<br />

| Parameters ||
|---|---|
| `ikeTunConnParams` | `IkeTunnelConnectionParams`: the `https://developer.android.com/reference/android/net/ipsec/ike/IkeTunnelConnectionParams` contains IKEv2 configurations. This value cannot be `null`. <br /> |

### Builder

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

```
public Builder (String serverAddr, 
                String identity)
```

Creates a new builder with the basic parameters of an IKEv2/IPsec VPN.


Requires the `https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_IPSEC_TUNNELS` feature which can be detected using `https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)`.

<br />

| Parameters ||
|---|---|
| `serverAddr` | `String`: the server that the VPN should connect to. This value cannot be `null`. <br /> |
| `identity` | `String`: the identity string to be used for IKEv2 authentication. This value cannot be `null`. <br /> |

## Public methods

### build

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

```
public Ikev2VpnProfile build ()
```

Validates, builds and provisions the VpnProfile.


Requires the `https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_IPSEC_TUNNELS` feature which can be detected using `https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Ikev2VpnProfile` | This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if any of the required keys or values were invalid |

### setAllowedAlgorithms

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

```
public Ikev2VpnProfile.Builder setAllowedAlgorithms (List<String> algorithmNames)
```

Sets the allowable set of IPsec algorithms

If set, this will constrain the set of algorithms that the IPsec tunnel will use for
integrity verification and encryption to the provided list.

The set of allowed IPsec algorithms is defined in `https://developer.android.com/reference/android/net/IpSecAlgorithm`. Adding of
algorithms that are considered insecure (such as AUTH_HMAC_MD5 and AUTH_HMAC_SHA1) is not
permitted, and will result in an IllegalArgumentException being thrown.

The provided algorithm list must contain at least one algorithm that provides
Authentication, and one that provides Encryption. Authenticated Encryption with
Associated Data (AEAD) algorithms provide both Authentication and Encryption.

If this `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` is constructed with an `https://developer.android.com/reference/android/net/ipsec/ike/IkeTunnelConnectionParams`,
authentication details should be configured there, and calling this method will result in
an exception being thrown.

By default, this profile will use any algorithm defined in `https://developer.android.com/reference/android/net/IpSecAlgorithm`,
with the exception of those considered insecure (as described above).


Requires the `https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_IPSEC_TUNNELS` feature which can be detected using `https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)`.

<br />

| Parameters ||
|---|---|
| `algorithmNames` | `List`: the list of supported IPsec algorithms. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | this `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` object to facilitate chaining of method calls. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/net/IpSecAlgorithm`

### setAuthDigitalSignature

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

```
public Ikev2VpnProfile.Builder setAuthDigitalSignature (X509Certificate userCert, 
                PrivateKey key, 
                X509Certificate serverRootCa)
```

Set the IKEv2 authentication to use Digital Signature Authentication with the given key.

Setting this will configure IKEv2 authentication using a Digital Signature scheme.
Only one authentication method may be set. This method will overwrite any previously set
authentication method.

If this `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` is constructed with an `https://developer.android.com/reference/android/net/ipsec/ike/IkeTunnelConnectionParams`,
authentication details should be configured there, and calling this method will result in
an exception being thrown.


Requires the `https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_IPSEC_TUNNELS` feature which can be detected using `https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)`.

<br />

| Parameters ||
|---|---|
| `userCert` | `X509Certificate`: the username to be used for RSA Digital signiture authentication. This value cannot be `null`. <br /> |
| `key` | `PrivateKey`: the PrivateKey instance associated with the user ceritificate, used for constructing the signature. This value cannot be `null`. <br /> |
| `serverRootCa` | `X509Certificate`: the root certificate to be used for verifying the identity of the server. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | this `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` object to facilitate chaining of method calls. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if any of the certificates were invalid or of an unrecognized format |

### setAuthPsk

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

```
public Ikev2VpnProfile.Builder setAuthPsk (byte[] psk)
```

Set the IKEv2 authentication to use Preshared keys.

Setting this will configure IKEv2 authentication using a Preshared Key. Only one
authentication method may be set. This method will overwrite any previously set
authentication method.

If this `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` is constructed with an `https://developer.android.com/reference/android/net/ipsec/ike/IkeTunnelConnectionParams`,
authentication details should be configured there, and calling this method will result in
an exception being thrown.


Requires the `https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_IPSEC_TUNNELS` feature which can be detected using `https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)`.

<br />

| Parameters ||
|---|---|
| `psk` | `byte`: the key to be used for Pre-Shared Key authentication. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | this `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` object to facilitate chaining of method calls. This value cannot be `null`. <br /> |

### setAuthUsernamePassword

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

```
public Ikev2VpnProfile.Builder setAuthUsernamePassword (String user, 
                String pass, 
                X509Certificate serverRootCa)
```

Set the IKEv2 authentication to use the provided username/password.

Setting this will configure IKEv2 authentication using EAP-MSCHAPv2. Only one
authentication method may be set. This method will overwrite any previously set
authentication method.

If this `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` is constructed with an `https://developer.android.com/reference/android/net/ipsec/ike/IkeTunnelConnectionParams`,
authentication details should be configured there, and calling this method will result
in an exception being thrown.


Requires the `https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_IPSEC_TUNNELS` feature which can be detected using `https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)`.

<br />

| Parameters ||
|---|---|
| `user` | `String`: the username to be used for EAP-MSCHAPv2 authentication. This value cannot be `null`. <br /> |
| `pass` | `String`: the password to be used for EAP-MSCHAPv2 authentication. This value cannot be `null`. <br /> |
| `serverRootCa` | `X509Certificate`: the root certificate to be used for verifying the identity of the server. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | this `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` object to facilitate chaining of method calls. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if any of the certificates were invalid or of an unrecognized format |

### setAutomaticIpVersionSelectionEnabled

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

```
public Ikev2VpnProfile.Builder setAutomaticIpVersionSelectionEnabled (boolean isEnabled)
```

Sets the enabled state of the automatic IP version selection.


Requires the `https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_IPSEC_TUNNELS` feature which can be detected using `https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)`.

<br />

| Parameters ||
|---|---|
| `isEnabled` | `boolean`: `true` to enable automatic IP version selection, based on internal platform signals. Defaults to `false`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | this `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` object to facilitate chaining of method calls. This value cannot be `null`. <br /> |

### setAutomaticNattKeepaliveTimerEnabled

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

```
public Ikev2VpnProfile.Builder setAutomaticNattKeepaliveTimerEnabled (boolean isEnabled)
```

Sets the enabled state of the automatic NAT-T keepalive timers

Note that if this builder was constructed with a `https://developer.android.com/reference/android/net/ipsec/ike/IkeTunnelConnectionParams`,
but this is called with `true`, the framework will automatically choose the
appropriate keepalive timer and ignore the settings in the session params embedded
in the connection params.


Requires the `https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_IPSEC_TUNNELS` feature which can be detected using `https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)`.

<br />

| Parameters ||
|---|---|
| `isEnabled` | `boolean`: `true` to enable automatic keepalive timers, based on internal platform signals. Defaults to `false`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | this `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` object to facilitate chaining of method calls. This value cannot be `null`. <br /> |

### setBypassable

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

```
public Ikev2VpnProfile.Builder setBypassable (boolean isBypassable)
```

Sets whether apps can bypass this VPN connection.

By default, all traffic from apps are forwarded through the VPN interface and it is
not possible for unprivileged apps to side-step the VPN. If a VPN is set to bypassable,
apps may use methods such as `https://developer.android.com/reference/android/net/Network#getSocketFactory()` or `https://developer.android.com/reference/android/net/Network#openConnection(java.net.URL)` to instead send/receive directly over the underlying network or
any other network they have permissions for.


Requires the `https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_IPSEC_TUNNELS` feature which can be detected using `https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)`.

<br />

| Parameters ||
|---|---|
| `isBypassable` | `boolean`: Whether or not the VPN should be considered bypassable. Defaults to `false`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | this `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` object to facilitate chaining of method calls. This value cannot be `null`. <br /> |

### setLocalRoutesExcluded

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

```
public Ikev2VpnProfile.Builder setLocalRoutesExcluded (boolean excludeLocalRoutes)
```

Sets whether the local traffic is exempted from the VPN.

When this is set, the system will not use the VPN network when an app
tries to send traffic for an IP address that is on a local network.

Note that there are important security implications. In particular, the
networks that the device connects to typically decides what IP addresses
are part of the local network. This means that for VPNs setting this
flag, it is possible for anybody to set up a public network in such a
way that traffic to arbitrary IP addresses will bypass the VPN, including
traffic to services like DNS. When using this API, please consider the
security implications for your particular case.

Note that because the local traffic will always bypass the VPN,
it is not possible to set this flag on a non-bypassable VPN.


Requires the `https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_IPSEC_TUNNELS` feature which can be detected using `https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)`.

<br />

| Parameters ||
|---|---|
| `excludeLocalRoutes` | `boolean` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | This value cannot be `null`. <br /> |

### setMaxMtu

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

```
public Ikev2VpnProfile.Builder setMaxMtu (int mtu)
```

Set the upper bound of the maximum transmission unit (MTU) of the VPN interface.

If it is not set, a safe value will be used. Additionally, the actual link MTU will be
dynamically calculated/updated based on the underlying link's mtu.


Requires the `https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_IPSEC_TUNNELS` feature which can be detected using `https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)`.

<br />

| Parameters ||
|---|---|
| `mtu` | `int`: the MTU (in bytes) of the VPN interface <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | this `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` object to facilitate chaining of method calls. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the value is not at least the minimum IPv6 MTU (1280) |

### setMetered

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

```
public Ikev2VpnProfile.Builder setMetered (boolean isMetered)
```

Marks the VPN network as metered.

A VPN network is classified as metered when the user is sensitive to heavy data usage
due to monetary costs and/or data limitations. In such cases, you should set this to
`true` so that apps on the system can avoid doing large data transfers. Otherwise,
set this to `false`. Doing so would cause VPN network to inherit its meteredness
from the underlying network.


Requires the `https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_IPSEC_TUNNELS` feature which can be detected using `https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)`.

<br />

| Parameters ||
|---|---|
| `isMetered` | `boolean`: `true` if the VPN network should be treated as metered regardless of underlying network meteredness. Defaults to `true`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | this `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` object to facilitate chaining of method calls. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_NOT_METERED`

### setProxy

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

```
public Ikev2VpnProfile.Builder setProxy (ProxyInfo proxy)
```

Sets a proxy for the VPN network.

Note that this proxy is only a recommendation and it may be ignored by apps.


Requires the `https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_IPSEC_TUNNELS` feature which can be detected using `https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)`.

<br />

| Parameters ||
|---|---|
| `proxy` | `ProxyInfo`: the ProxyInfo to be set for the VPN network. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | this `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` object to facilitate chaining of method calls. This value cannot be `null`. <br /> |

### setRequiresInternetValidation

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

```
public Ikev2VpnProfile.Builder setRequiresInternetValidation (boolean requiresInternetValidation)
```

Request that this VPN undergoes Internet validation.

If this is true, the platform will perform basic validation checks for Internet
connectivity over this VPN. If and when they succeed, the VPN network capabilities will
reflect this by gaining the `https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_VALIDATED`
capability.

If this is false, the platform assumes the VPN either is always capable of reaching the
Internet or intends not to. In this case, the VPN network capabilities will
always gain the `https://developer.android.com/reference/android/net/NetworkCapabilities#NET_CAPABILITY_VALIDATED` capability
immediately after it connects, whether it can reach public Internet destinations or not.


Requires the `https://developer.android.com/reference/android/content/pm/PackageManager#FEATURE_IPSEC_TUNNELS` feature which can be detected using `https://developer.android.com/reference/android/content/pm/PackageManager#hasSystemFeature(java.lang.String)`.

<br />

| Parameters ||
|---|---|
| `requiresInternetValidation` | `boolean`: `true` if the framework should attempt to validate this VPN for Internet connectivity. Defaults to `false`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/Ikev2VpnProfile.Builder` | This value cannot be `null`. <br /> |