public static class NetworkRequest.Builder extends Object
NetworkRequest
objects. Specify the Network features
needed in terms of NetworkCapabilities
featuresConstructor and Description |
---|
Builder()
Default constructor for Builder.
|
Modifier and Type | Method and Description |
---|---|
NetworkRequest.Builder |
addCapability(int capability)
Add the given capability requirement to this builder.
|
NetworkRequest.Builder |
addTransportType(int transportType)
Adds the given transport requirement to this builder.
|
NetworkRequest |
build()
Build
NetworkRequest give the current set of capabilities. |
NetworkRequest.Builder |
clearCapabilities()
Completely clears all the
NetworkCapabilities from this builder instance,
removing even the capabilities that are set by default when the object is constructed. |
NetworkRequest.Builder |
removeCapability(int capability)
Removes (if found) the given capability from this builder instance.
|
NetworkRequest.Builder |
removeTransportType(int transportType)
Removes (if found) the given transport from this builder instance.
|
NetworkRequest.Builder |
setLinkDownstreamBandwidthKbps(int downKbps) |
NetworkRequest.Builder |
setLinkUpstreamBandwidthKbps(int upKbps) |
NetworkRequest.Builder |
setNetworkSpecifier(String networkSpecifier)
Sets the optional bearer specific network specifier.
|
NetworkRequest.Builder |
setSignalStrength(int signalStrength)
Sets the signal strength.
|
public NetworkRequest build()
NetworkRequest
give the current set of capabilities.public NetworkRequest.Builder addCapability(int capability)
NetworkCapabilities
for NET_CAPABILITY_*
definitions.capability
- The NetworkCapabilities.NET_CAPABILITY_*
to add.builder.addCapability(...).addCapability();
.public NetworkRequest.Builder removeCapability(int capability)
capability
- The NetworkCapabilities.NET_CAPABILITY_*
to remove.public NetworkRequest.Builder clearCapabilities()
NetworkCapabilities
from this builder instance,
removing even the capabilities that are set by default when the object is constructed.public NetworkRequest.Builder addTransportType(int transportType)
NetworkCapabilities
for TRANSPORT_*
definitions.transportType
- The NetworkCapabilities.TRANSPORT_*
to add.public NetworkRequest.Builder removeTransportType(int transportType)
transportType
- The NetworkCapabilities.TRANSPORT_*
to remove.public NetworkRequest.Builder setLinkUpstreamBandwidthKbps(int upKbps)
public NetworkRequest.Builder setLinkDownstreamBandwidthKbps(int downKbps)
public NetworkRequest.Builder setNetworkSpecifier(String networkSpecifier)
String
is bearer specific and bearers that use
it should document their particulars. For example, Bluetooth may use some sort of
device id while WiFi could used ssid and/or bssid. Cellular may use carrier spn.networkSpecifier
- An String
of opaque format used to specify the bearer
specific network specifier where the bearer has a choice of
networks.public NetworkRequest.Builder setSignalStrength(int signalStrength)
Note that when used to register a network callback, this specifies the minimum acceptable
signal strength. When received as the state of an existing network it specifies the
current value. A value of SIGNAL_STRENGTH_UNSPECIFIED
means no value when
received and has no effect when requesting a callback.
signalStrength
- the bearer-specific signal strength.