Builder
class Builder
| kotlin.Any | |
| ↳ | android.security.NetworkSecurityPolicy.Builder |
A builder for a NetworkSecurityPolicy.
Summary
| Public constructors | |
|---|---|
|
Creates a builder for the network security policy. |
|
|
Creates a builder for the network security policy. |
|
| Public methods | |
|---|---|
| NetworkSecurityPolicy.Builder |
addDomainConfig(domain: Domain, config: NetworkSecurityConfig)Adds a config for the provided domain (see domain-config docs). |
| NetworkSecurityPolicy |
build()Creates a |
| NetworkSecurityPolicy.Builder |
setBaseConfig(config: NetworkSecurityConfig)Sets the base config for this network security policy (see base-config docs). |
| NetworkSecurityPolicy.Builder |
setLocalhostConfig(config: NetworkSecurityConfig)Sets the localhost config for this network security policy (see Localhost config docs). |
Public constructors
Builder
Builder(appContext: Context)
Creates a builder for the network security policy. The builder is initialized with default values of the app's SDK target level.
| Parameters | |
|---|---|
appContext |
Context: the application Context. Must not be null. |
Builder
Builder(
appContext: Context,
inheritNetworkSecurityConfig: Boolean)
Creates a builder for the network security policy. The builder is initialized with either the content of the app's Network Security Config XML, or with the default values of the app's SDK target level.
| Parameters | |
|---|---|
appContext |
Context: the application Context. Must not be null. |
inheritNetworkSecurityConfig |
Boolean: if true, initialize the builder with the content of the app's network security config. If false, initialize the builder with the default values of the app's SDK level. |
Public methods
addDomainConfig
fun addDomainConfig(
domain: Domain,
config: NetworkSecurityConfig
): NetworkSecurityPolicy.Builder
Adds a config for the provided domain (see domain-config docs). Any existing config for the domain will be replaced.
| Parameters | |
|---|---|
domain |
Domain: the domain. Must not be null. |
config |
NetworkSecurityConfig: the config to use as the domain config. This value cannot be null. |
| Return | |
|---|---|
NetworkSecurityPolicy.Builder |
the builder. This value cannot be null. |
build
fun build(): NetworkSecurityPolicy
Creates a NetworkSecurityPolicy with the arguments provided to this builder.
| Return | |
|---|---|
NetworkSecurityPolicy |
a NetworkSecurityPolicy This value cannot be null. |
setBaseConfig
fun setBaseConfig(config: NetworkSecurityConfig): NetworkSecurityPolicy.Builder
Sets the base config for this network security policy (see base-config docs). If unset, the base-config in the Network Security Configuration XML file of the app provided at Builder construction is used.
| Parameters | |
|---|---|
config |
NetworkSecurityConfig: the config to use as the base config. This value cannot be null. |
| Return | |
|---|---|
NetworkSecurityPolicy.Builder |
the builder. This value cannot be null. |
setLocalhostConfig
fun setLocalhostConfig(config: NetworkSecurityConfig): NetworkSecurityPolicy.Builder
Sets the localhost config for this network security policy (see Localhost config docs).
| Parameters | |
|---|---|
config |
NetworkSecurityConfig: the config to use as the localhost config. This value cannot be null. |
| Return | |
|---|---|
NetworkSecurityPolicy.Builder |
the builder. This value cannot be null. |