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

### Public Method Summary

|--------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| [DnsOptions.StaleDnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html) | [allowCrossNetworkUsage](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#allowCrossNetworkUsage(boolean))(boolean allowCrossNetworkUsage) Sets whether to return results originating from other networks or not.                                                                                                                                                                                                                                                            |
| [DnsOptions.StaleDnsOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.html)                 | [build](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#build())() Creates and returns the final[DnsOptions.StaleDnsOptions](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.html)instance, based on the values in this builder.                                                                                                                                                                            |
| [DnsOptions.StaleDnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html) | [setFreshLookupTimeout](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#setFreshLookupTimeout(java.time.Duration))(Duration freshLookupTimeout) Same as[setFreshLookupTimeoutMillis(long)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#setFreshLookupTimeoutMillis(long))but using[Duration](https://developer.android.com/develop/connectivity/cronet/reference/java/time/Duration.html). |
| [DnsOptions.StaleDnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html) | [setFreshLookupTimeoutMillis](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#setFreshLookupTimeoutMillis(long))(long freshLookupTimeoutMillis) Sets how long (in milliseconds) to wait for a DNS request to return before using a stale result instead.                                                                                                                                                                                                                    |
| [DnsOptions.StaleDnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html) | [setMaxExpiredDelayMillis](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#setMaxExpiredDelayMillis(long))(long maxExpiredDelayMillis) Sets how long (in milliseconds) past expiration to consider using expired results.                                                                                                                                                                                                                                                   |
| [DnsOptions.StaleDnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html) | [setMaxExpiredDelayMillis](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#setMaxExpiredDelayMillis(java.time.Duration))(Duration maxExpiredDelay) Same as[setMaxExpiredDelayMillis(long)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#setMaxExpiredDelayMillis(long))but using[Duration](https://developer.android.com/develop/connectivity/cronet/reference/java/time/Duration.html).    |
| [DnsOptions.StaleDnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html) | [useStaleOnNameNotResolved](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#useStaleOnNameNotResolved(boolean))(boolean useStaleOnNameNotResolved) Sets whether to allow use of stale DNS results when network resolver fails to resolve the hostname.                                                                                                                                                                                                                      |

### 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[DnsOptions.StaleDnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html)**allowCrossNetworkUsage**(boolean allowCrossNetworkUsage)

Sets whether to return results originating from other networks or not. Normally, Cronet clears the DNS cache entirely when switching connections, e.g. between two Wi-Fi networks or from Wi-Fi to 4G.  

##### Parameters

| allowCrossNetworkUsage |   |
|------------------------|---|

##### Returns

- the builder for chaining  

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

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

#### public[DnsOptions.StaleDnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html)**setFreshLookupTimeout**(Duration freshLookupTimeout)

Same as[setFreshLookupTimeoutMillis(long)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#setFreshLookupTimeoutMillis(long))but using[Duration](https://developer.android.com/develop/connectivity/cronet/reference/java/time/Duration.html).  

##### Parameters

| freshLookupTimeout |   |
|--------------------|---|

##### Returns

- the builder for chaining  

#### public[DnsOptions.StaleDnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html)**setFreshLookupTimeoutMillis**(long freshLookupTimeoutMillis)

Sets how long (in milliseconds) to wait for a DNS request to return before using a stale result instead. If set to zero, returns stale results instantly but continues the DNS request in the background to update the cache.  

##### Parameters

| freshLookupTimeoutMillis |   |
|--------------------------|---|

##### Returns

- the builder for chaining  

#### public[DnsOptions.StaleDnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html)**setMaxExpiredDelayMillis**(long maxExpiredDelayMillis)

Sets how long (in milliseconds) past expiration to consider using expired results. Setting the value to zero means expired records can be used indefinitely.  

##### Parameters

| maxExpiredDelayMillis |   |
|-----------------------|---|

##### Returns

- the builder for chaining  

#### public[DnsOptions.StaleDnsOptions.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html)**setMaxExpiredDelayMillis**(Duration maxExpiredDelay)

Same as[setMaxExpiredDelayMillis(long)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html#setMaxExpiredDelayMillis(long))but using[Duration](https://developer.android.com/develop/connectivity/cronet/reference/java/time/Duration.html).  

##### Parameters

| maxExpiredDelay |   |
|-----------------|---|

##### Returns

- the builder for chaining  

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

Sets whether to allow use of stale DNS results when network resolver fails to resolve the hostname.

Depending on the use case, if Cronet quickly sees a fresh failure, it may be desirable to use the failure as it is technically the fresher result, and we had such a fresh result quickly; or, prefer having any result (even if stale) to use over having a failure.  

##### Parameters

| useStaleOnNameNotResolved |   |
|---------------------------|---|

##### Returns

- the builder for chaining