Added in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [S Extensions 7](https://developer.android.com/sdkExtensions) Summary: [Ctors](https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions.Builder#pubctors) \| [Methods](https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions.Builder#inhmethods)

# ConnectionMigrationOptions.Builder

*** ** * ** ***


`
public
static
final

class
ConnectionMigrationOptions.Builder
`


`

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


`

`


`

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

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions`.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions.Builder#Builder()() ` |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions` | ` https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions.Builder#build()() ` Creates and returns the final `https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions` instance, based on the values in this builder. |
| ` https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions.Builder` | ` https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions.Builder#setAllowNonDefaultNetworkUsage(int)(int state) ` Sets whether connections can be migrated to an alternate network when Cronet detects a degradation of the path currently in use. |
| ` https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions.Builder` | ` https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions.Builder#setDefaultNetworkMigration(int)(int state) ` Sets whether to enable the possibility of migrating connections on default network change. |
| ` https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions.Builder` | ` https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions.Builder#setPathDegradationMigration(int)(int state) ` Sets whether to enable the possibility of migrating connections if the current path is performing poorly. |

| ### 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 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Also in [S Extensions 7](https://developer.android.com/sdkExtensions)

```
public Builder ()
```

<br />

<br />

## Public methods

### build

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

```
public ConnectionMigrationOptions build ()
```

Creates and returns the final `https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions` instance, based on the
values in this builder.

<br />

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

### setAllowNonDefaultNetworkUsage

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

```
public ConnectionMigrationOptions.Builder setAllowNonDefaultNetworkUsage (int state)
```

Sets whether connections can be migrated to an alternate network when Cronet detects
a degradation of the path currently in use. Requires setting
`https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions.Builder#setPathDegradationMigration(int)` to `https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions#MIGRATION_OPTION_ENABLED` to
have any effect.

Note: This setting can result in requests being sent on non-default metered networks,
eating into the users' data budgets and incurring extra costs. Make sure you're using
metered networks sparingly.

<br />

| Parameters ||
|---|---|
| `state` | `int`: one of the MIGRATION_OPTION_\* values. Value is one of the following: - `https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions#MIGRATION_OPTION_UNSPECIFIED` - `https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions#MIGRATION_OPTION_ENABLED` - `https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions#MIGRATION_OPTION_DISABLED` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions.Builder` | this builder for chaining. This value cannot be `null`. <br /> |

### setDefaultNetworkMigration

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

```
public ConnectionMigrationOptions.Builder setDefaultNetworkMigration (int state)
```

Sets whether to enable the possibility of migrating connections on default network
change. If enabled, active QUIC connections will be migrated onto the new network when
the platform indicates that the default network is changing.

<br />

| Parameters ||
|---|---|
| `state` | `int`: one of the MIGRATION_OPTION_\* values. Value is one of the following: - `https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions#MIGRATION_OPTION_UNSPECIFIED` - `https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions#MIGRATION_OPTION_ENABLED` - `https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions#MIGRATION_OPTION_DISABLED` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions.Builder` | this builder for chaining. This value cannot be `null`. <br /> |

**See also:**

- [Android
  Network State](https://developer.android.com/training/basics/network-ops/reading-network-state#listening-events)

### setPathDegradationMigration

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

```
public ConnectionMigrationOptions.Builder setPathDegradationMigration (int state)
```

Sets whether to enable the possibility of migrating connections if the current path is
performing poorly.

Depending on other configuration, this can result to migrating the connections within
the same default network, or to a non-default network.

<br />

| Parameters ||
|---|---|
| `state` | `int`: one of the MIGRATION_OPTION_\* values. Value is one of the following: - `https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions#MIGRATION_OPTION_UNSPECIFIED` - `https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions#MIGRATION_OPTION_ENABLED` - `https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions#MIGRATION_OPTION_DISABLED` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/http/ConnectionMigrationOptions.Builder` | this builder for chaining. This value cannot be `null`. <br /> |