public static class**ConnectionMigrationOptions.Builder** extends Object  
Builder for[ConnectionMigrationOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.html).  

### Public Method Summary

|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html) | [allowNonDefaultNetworkUsage](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html#allowNonDefaultNetworkUsage(boolean))(boolean enable) Sets whether connections can be migrated to an alternate network when Cronet detects a degradation of the path currently in use.                                                                       |
| [ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html) | [allowServerMigration](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html#allowServerMigration(boolean))(boolean allowServerMigration) Enables the possibility of migrating connections to an alternate server address at the server's request.                                                                                               |
| [ConnectionMigrationOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.html)                 | [build](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html#build())() Creates and returns the final[ConnectionMigrationOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.html)instance, based on the values in this builder.                                           |
| [ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html) | [enableDefaultNetworkMigration](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html#enableDefaultNetworkMigration(boolean))(boolean enableDefaultNetworkConnectionMigration) Enables the possibility of migrating connections on default network change.                                                                                       |
| [ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html) | [enablePathDegradationMigration](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html#enablePathDegradationMigration(boolean))(boolean enable) Enables the possibility of migrating connections if the current path is performing poorly.                                                                                                       |
| [ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html) | [migrateIdleConnections](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html#migrateIdleConnections(boolean))(boolean migrateIdleConnections) Configures whether migration of idle connections should be enabled or not.                                                                                                                       |
| [ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html) | [retryPreHandshakeErrorsOnNonDefaultNetwork](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html#retryPreHandshakeErrorsOnNonDefaultNetwork(boolean))(boolean retryPreHandshakeErrorsOnAlternateNetwork) Sets whether connections with pre-handshake errors should be retried on an alternative network.                                       |
| [ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html) | [setIdleConnectionMigrationPeriodSeconds](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html#setIdleConnectionMigrationPeriodSeconds(long))(long idleConnectionMigrationPeriodSeconds) Sets the maximum idle period for which connections will still be migrated, in seconds.                                                                 |
| [ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html) | [setMaxPathDegradingNonDefaultNetworkMigrationsCount](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html#setMaxPathDegradingNonDefaultNetworkMigrationsCount(int))(int maxPathDegradingEagerMigrationsCount) Sets the maximum number of migrations to the non-default network upon encountering path degradation for the existing connection. |
| [ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html) | [setMaxTimeOnNonDefaultNetworkSeconds](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html#setMaxTimeOnNonDefaultNetworkSeconds(long))(long maxTimeOnNonDefaultNetworkSeconds) Sets the maximum period for which eagerly migrated connections should remain on the non-default network before they're migrated back.                           |
| [ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html) | [setMaxWriteErrorNonDefaultNetworkMigrationsCount](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html#setMaxWriteErrorNonDefaultNetworkMigrationsCount(int))(int maxWriteErrorEagerMigrationsCount) Sets the maximum number of migrations to the non-default network upon encountering write errors.                                          |

### Inherited Method Summary

From class java.lang.Object  

|------------------|---------------------------|
| Object           | clone()                   |
| boolean          | equals(Object arg0)       |
| void             | finalize()                |
| final Class\<?\> | getClass()                |
| int              | hashCode()                |
| final void       | notify()                  |
| final void       | notifyAll()               |
| String           | toString()                |
| final void       | wait(long arg0, int arg1) |
| final void       | wait(long arg0)           |
| final void       | wait()                    |

## Public Methods

#### public[ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html)**allowNonDefaultNetworkUsage**(boolean enable)

Sets whether connections can be migrated to an alternate network when Cronet detects a degradation of the path currently in use.

Note: This setting can result in requests being sent on non-default metered networks. Make sure you're using metered networks sparingly, and fine tune parameters like[setMaxPathDegradingNonDefaultNetworkMigrationsCount(int)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html#setMaxPathDegradingNonDefaultNetworkMigrationsCount(int))and[setMaxTimeOnNonDefaultNetworkSeconds(long)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html#setMaxTimeOnNonDefaultNetworkSeconds(long))to limit the time on non-default networks.  

##### Parameters

| enable |   |
|--------|---|

##### Returns

- this builder for chaining  

#### public[ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html)**allowServerMigration**(boolean allowServerMigration)

Enables the possibility of migrating connections to an alternate server address at the server's request.  

##### Parameters

| allowServerMigration |   |
|----------------------|---|

##### Returns

- this builder for chaining  

#### public[ConnectionMigrationOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.html)**build**()

Creates and returns the final[ConnectionMigrationOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.html)instance, based on the values in this builder.  

#### public[ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html)**enableDefaultNetworkMigration**(boolean enableDefaultNetworkConnectionMigration)

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

##### Parameters

| enableDefaultNetworkConnectionMigration |   |
|-----------------------------------------|---|

##### Returns

- this builder for chaining  

##### See Also

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

#### public[ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html)**enablePathDegradationMigration**(boolean enable)

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

##### Parameters

| enable |   |
|--------|---|

##### Returns

- this builder for chaining  

##### See Also

- [allowNonDefaultNetworkUsage(boolean)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html#allowNonDefaultNetworkUsage(boolean))  

#### public[ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html)**migrateIdleConnections**(boolean migrateIdleConnections)

Configures whether migration of idle connections should be enabled or not.

If set to true, idle connections will be migrated too, as long as they haven't been idle for too long. The setting is shared for all connection migration types. The maximum idle period for which connections will still be migrated can be customized using[setIdleConnectionMigrationPeriodSeconds(long)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html#setIdleConnectionMigrationPeriodSeconds(long)).  

##### Parameters

| migrateIdleConnections |   |
|------------------------|---|

##### Returns

- this builder for chaining  

#### public[ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html)**retryPreHandshakeErrorsOnNonDefaultNetwork**(boolean retryPreHandshakeErrorsOnAlternateNetwork)

Sets whether connections with pre-handshake errors should be retried on an alternative network.

If true, a new connection may be established an alternate network if it fails on the default network before handshake is confirmed.

Note: similarly to[allowNonDefaultNetworkUsage(boolean)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html#allowNonDefaultNetworkUsage(boolean))this setting can result in requests being sent on non-default metered networks. Use with caution!  

##### Parameters

| retryPreHandshakeErrorsOnAlternateNetwork |   |
|-------------------------------------------|---|

##### Returns

- this builder for chaining  

#### public[ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html)**setIdleConnectionMigrationPeriodSeconds**(long idleConnectionMigrationPeriodSeconds)

Sets the maximum idle period for which connections will still be migrated, in seconds. The setting is shared for all connection migration types.

Only relevant if[migrateIdleConnections(boolean)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html#migrateIdleConnections(boolean))is enabled.  

##### Parameters

| idleConnectionMigrationPeriodSeconds |   |
|--------------------------------------|---|

##### Returns

- this builder for chaining  

#### public[ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html)**setMaxPathDegradingNonDefaultNetworkMigrationsCount**(int maxPathDegradingEagerMigrationsCount)

Sets the maximum number of migrations to the non-default network upon encountering path degradation for the existing connection. Counted cumulatively per network per connection.

Only relevant if[allowNonDefaultNetworkUsage(boolean)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html#allowNonDefaultNetworkUsage(boolean))is enabled.  

##### Parameters

| maxPathDegradingEagerMigrationsCount |   |
|--------------------------------------|---|

##### Returns

- this builder for chaining  

#### public[ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html)**setMaxTimeOnNonDefaultNetworkSeconds**(long maxTimeOnNonDefaultNetworkSeconds)

Sets the maximum period for which eagerly migrated connections should remain on the non-default network before they're migrated back. This time is not cumulative - each migration off the default network for each connection measures and compares to this value separately.

Only relevant if[allowNonDefaultNetworkUsage(boolean)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html#allowNonDefaultNetworkUsage(boolean))is enabled.  

##### Parameters

| maxTimeOnNonDefaultNetworkSeconds |   |
|-----------------------------------|---|

##### Returns

- this builder for chaining  

#### public[ConnectionMigrationOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html)**setMaxWriteErrorNonDefaultNetworkMigrationsCount**(int maxWriteErrorEagerMigrationsCount)

Sets the maximum number of migrations to the non-default network upon encountering write errors. Counted cumulatively per network per connection.

Only relevant if[allowNonDefaultNetworkUsage(boolean)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/ConnectionMigrationOptions.Builder.html#allowNonDefaultNetworkUsage(boolean))is enabled.  

##### Parameters

| maxWriteErrorEagerMigrationsCount |   |
|-----------------------------------|---|

##### Returns

- this builder for chaining