Builder
open class Builder
| kotlin.Any | |
| ↳ | android.net.NetworkRequest.Builder |
Builder used to create NetworkRequest objects. Specify the Network features needed in terms of NetworkCapabilities features
Summary
Public constructors |
|
|---|---|
<init>()Default constructor for Builder. |
|
Public methods |
|
|---|---|
| open NetworkRequest.Builder! |
addCapability(capability: Int)Add the given capability requirement to this builder. |
| open NetworkRequest.Builder! |
addTransportType(transportType: Int)Adds the given transport requirement to this builder. |
| open NetworkRequest! |
build()Build |
| open NetworkRequest.Builder |
Completely clears all the |
| open NetworkRequest.Builder! |
removeCapability(capability: Int)Removes (if found) the given capability from this builder instance. |
| open NetworkRequest.Builder! |
removeTransportType(transportType: Int)Removes (if found) the given transport from this builder instance. |
| open NetworkRequest.Builder! |
setNetworkSpecifier(networkSpecifier: String!)Sets the optional bearer specific network specifier. |
| open NetworkRequest.Builder! |
setNetworkSpecifier(networkSpecifier: NetworkSpecifier!)Sets the optional bearer specific network specifier. |
Public constructors
Public methods
addCapability
open fun addCapability(capability: Int): NetworkRequest.Builder!
Add the given capability requirement to this builder. These represent the requested network's required capabilities. Note that when searching for a network to satisfy a request, all capabilities requested must be satisfied.
| Return | |
|---|---|
NetworkRequest.Builder! |
The builder to facilitate chaining builder.addCapability(...).addCapability();. |
addTransportType
open fun addTransportType(transportType: Int): NetworkRequest.Builder!
Adds the given transport requirement to this builder. These represent the set of allowed transports for the request. Only networks using one of these transports will satisfy the request. If no particular transports are required, none should be specified here.
| Parameters | |
|---|---|
transportType |
Int: The transport type to add. Value is android.net.NetworkCapabilities#TRANSPORT_CELLULAR, android.net.NetworkCapabilities#TRANSPORT_WIFI, android.net.NetworkCapabilities#TRANSPORT_BLUETOOTH, android.net.NetworkCapabilities#TRANSPORT_ETHERNET, android.net.NetworkCapabilities#TRANSPORT_VPN, android.net.NetworkCapabilities#TRANSPORT_WIFI_AWARE, android.net.NetworkCapabilities#TRANSPORT_LOWPAN, or android.net.NetworkCapabilities.TRANSPORT_TEST |
| Return | |
|---|---|
NetworkRequest.Builder! |
The builder to facilitate chaining. |
build
open fun build(): NetworkRequest!
Build NetworkRequest give the current set of capabilities.
clearCapabilities
open fun clearCapabilities(): NetworkRequest.Builder
Completely clears all the NetworkCapabilities from this builder instance, removing even the capabilities that are set by default when the object is constructed.
| Return | |
|---|---|
NetworkRequest.Builder |
The builder to facilitate chaining. This value cannot be null. |
removeCapability
open fun removeCapability(capability: Int): NetworkRequest.Builder!
Removes (if found) the given capability from this builder instance.
| Return | |
|---|---|
NetworkRequest.Builder! |
The builder to facilitate chaining. |
removeTransportType
open fun removeTransportType(transportType: Int): NetworkRequest.Builder!
Removes (if found) the given transport from this builder instance.
| Parameters | |
|---|---|
transportType |
Int: The transport type to remove. Value is android.net.NetworkCapabilities#TRANSPORT_CELLULAR, android.net.NetworkCapabilities#TRANSPORT_WIFI, android.net.NetworkCapabilities#TRANSPORT_BLUETOOTH, android.net.NetworkCapabilities#TRANSPORT_ETHERNET, android.net.NetworkCapabilities#TRANSPORT_VPN, android.net.NetworkCapabilities#TRANSPORT_WIFI_AWARE, android.net.NetworkCapabilities#TRANSPORT_LOWPAN, or android.net.NetworkCapabilities.TRANSPORT_TEST |
| Return | |
|---|---|
NetworkRequest.Builder! |
The builder to facilitate chaining. |
setNetworkSpecifier
open funsetNetworkSpecifier(networkSpecifier: String!): NetworkRequest.Builder!
Deprecated: Use setNetworkSpecifier(android.net.NetworkSpecifier) instead.
Sets the optional bearer specific network specifier. This has no meaning if a single transport is also not specified, so calling this without a single transport set will generate an exception, as will subsequently adding or removing transports after this is set.
If thenetworkSpecifier is provided, it shall be interpreted as follows:
- If the specifier can be parsed as an integer, it will be treated as a
TelephonyNetworkSpecifier, and the provided integer will be interpreted as a SubscriptionId. - If the value is an ethernet interface name, it will be treated as such.
- For all other cases, the behavior is undefined.
| Parameters | |
|---|---|
networkSpecifier |
String!: A String of either a SubscriptionId in cellular network request or an ethernet interface name in ethernet network request. |
setNetworkSpecifier
open fun setNetworkSpecifier(networkSpecifier: NetworkSpecifier!): NetworkRequest.Builder!
Sets the optional bearer specific network specifier. This has no meaning if a single transport is also not specified, so calling this without a single transport set will generate an exception, as will subsequently adding or removing transports after this is set.
| Parameters | |
|---|---|
networkSpecifier |
NetworkSpecifier!: A concrete, parcelable framework class that extends NetworkSpecifier. |