# DnsOptions.StaleDnsOptions

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

# StaleDnsOptions

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/net/http/DnsOptions.StaleDnsOptions "View this page in Java")  

```
class StaleDnsOptions
```

|---|--------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                             ||
| ↳ | [android.net.http.DnsOptions.StaleDnsOptions](https://developer.android.com/reference/kotlin/android/net/http/DnsOptions.StaleDnsOptions#) |

A class configuring the stale DNS functionality.

DNS resolution is one of the steps on the critical path to making a URL request, but it can be slow for various reasons (underlying network latency, buffer bloat, packet loss, etc.). Depending on the use case, it might be worthwhile for an app developer to trade off guaranteed DNS record freshness for better availability of DNS records.

Stale results can include both:

- results returned from the current network's DNS server, but past their time-to-live, and
- results returned from a different network's DNS server, whether expired or not.

For detailed explanation of the configuration options see javadoc on[StaleDnsOptions.Builder](https://developer.android.com/reference/kotlin/android/net/http/DnsOptions.StaleDnsOptions.Builder)methods.

## Summary

|                                                                                                               Nested classes                                                                                                                ||
|---|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|   | [Builder](https://developer.android.com/reference/kotlin/android/net/http/DnsOptions.StaleDnsOptions.Builder) Builder for[StaleDnsOptions](https://developer.android.com/reference/kotlin/android/net/http/DnsOptions.StaleDnsOptions#). |

|                                                                                                                         Public methods                                                                                                                         ||
|------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)           | [getAllowCrossNetworkUsage](https://developer.android.com/reference/kotlin/android/net/http/DnsOptions.StaleDnsOptions#getAllowCrossNetworkUsage())`()` <br />       |
| open[Duration](https://developer.android.com/reference/kotlin/java/time/Duration.html#)? | [getFreshLookupTimeout](https://developer.android.com/reference/kotlin/android/net/http/DnsOptions.StaleDnsOptions#getFreshLookupTimeout())`()` <br />               |
| open[Duration](https://developer.android.com/reference/kotlin/java/time/Duration.html#)? | [getMaxExpiredDelay](https://developer.android.com/reference/kotlin/android/net/http/DnsOptions.StaleDnsOptions#getMaxExpiredDelay())`()` <br />                     |
| open[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)           | [getUseStaleOnNameNotResolved](https://developer.android.com/reference/kotlin/android/net/http/DnsOptions.StaleDnsOptions#getUseStaleOnNameNotResolved())`()` <br /> |

## Public methods

### getAllowCrossNetworkUsage

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

```
open fun getAllowCrossNetworkUsage(): Int
```

|                                                                                                                                                                                                                                                                                      Return                                                                                                                                                                                                                                                                                       ||
|----------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | Value is[android.net.http.DnsOptions#DNS_OPTION_UNSPECIFIED](https://developer.android.com/reference/kotlin/android/net/http/DnsOptions#DNS_OPTION_UNSPECIFIED:kotlin.Int),[android.net.http.DnsOptions#DNS_OPTION_ENABLED](https://developer.android.com/reference/kotlin/android/net/http/DnsOptions#DNS_OPTION_ENABLED:kotlin.Int), or[android.net.http.DnsOptions#DNS_OPTION_DISABLED](https://developer.android.com/reference/kotlin/android/net/http/DnsOptions#DNS_OPTION_DISABLED:kotlin.Int) |

### getFreshLookupTimeout

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

```
open fun getFreshLookupTimeout(): Duration?
```

|                                                     Return                                                     ||
|--------------------------------------------------------------------------------------|--------------------------|
| [Duration](https://developer.android.com/reference/kotlin/java/time/Duration.html#)? | This value may be`null`. |

### getMaxExpiredDelay

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

```
open fun getMaxExpiredDelay(): Duration?
```

|                                                     Return                                                     ||
|--------------------------------------------------------------------------------------|--------------------------|
| [Duration](https://developer.android.com/reference/kotlin/java/time/Duration.html#)? | This value may be`null`. |

### getUseStaleOnNameNotResolved

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

```
open fun getUseStaleOnNameNotResolved(): Int
```

|                                                                                                                                                                                                                                                                                      Return                                                                                                                                                                                                                                                                                       ||
|----------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | Value is[android.net.http.DnsOptions#DNS_OPTION_UNSPECIFIED](https://developer.android.com/reference/kotlin/android/net/http/DnsOptions#DNS_OPTION_UNSPECIFIED:kotlin.Int),[android.net.http.DnsOptions#DNS_OPTION_ENABLED](https://developer.android.com/reference/kotlin/android/net/http/DnsOptions#DNS_OPTION_ENABLED:kotlin.Int), or[android.net.http.DnsOptions#DNS_OPTION_DISABLED](https://developer.android.com/reference/kotlin/android/net/http/DnsOptions#DNS_OPTION_DISABLED:kotlin.Int) |