NetworkSecurityPolicy.Builder


public static final class NetworkSecurityPolicy.Builder
extends Object

java.lang.Object
   ↳ android.security.NetworkSecurityPolicy.Builder


A builder for a NetworkSecurityPolicy.

Summary

Public constructors

Builder(Context appContext)

Creates a builder for the network security policy.

Builder(Context appContext, boolean inheritNetworkSecurityConfig)

Creates a builder for the network security policy.

Public methods

NetworkSecurityPolicy.Builder addDomainConfig(Domain domain, NetworkSecurityConfig config)

Adds a config for the provided domain (see domain-config docs).

NetworkSecurityPolicy build()

Creates a NetworkSecurityPolicy with the arguments provided to this builder.

NetworkSecurityPolicy.Builder setBaseConfig(NetworkSecurityConfig config)

Sets the base config for this network security policy (see base-config docs).

NetworkSecurityPolicy.Builder setLocalhostConfig(NetworkSecurityConfig config)

Sets the localhost config for this network security policy (see Localhost config docs).

Inherited methods

Public constructors

Builder

Added in API level 10000
public Builder (Context appContext)

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

Added in API level 10000
public Builder (Context appContext, 
                boolean inheritNetworkSecurityConfig)

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

Added in API level 10000
public NetworkSecurityPolicy.Builder addDomainConfig (Domain domain, 
                NetworkSecurityConfig config)

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.

Returns
NetworkSecurityPolicy.Builder the builder.
This value cannot be null.

build

Added in API level 10000
public NetworkSecurityPolicy build ()

Creates a NetworkSecurityPolicy with the arguments provided to this builder.

Returns
NetworkSecurityPolicy a NetworkSecurityPolicy
This value cannot be null.

setBaseConfig

Added in API level 10000
public NetworkSecurityPolicy.Builder setBaseConfig (NetworkSecurityConfig config)

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.

Returns
NetworkSecurityPolicy.Builder the builder.
This value cannot be null.

setLocalhostConfig

Added in API level 10000
public NetworkSecurityPolicy.Builder setLocalhostConfig (NetworkSecurityConfig config)

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.

Returns
NetworkSecurityPolicy.Builder the builder.
This value cannot be null.