# Print output for @column tags ?>
public
static
final
class
WifiNetworkSpecifier.Builder
extends Object
java.lang.Object | |
↳ | android.net.wifi.WifiNetworkSpecifier.Builder |
Builder used to create WifiNetworkSpecifier
objects.
Public constructors | |
---|---|
Builder()
|
Public methods | |
---|---|
WifiNetworkSpecifier
|
build()
Create a specifier object used to request a local Wi-Fi network. |
WifiNetworkSpecifier.Builder
|
setBssid(MacAddress bssid)
Set the BSSID to use for filtering networks from scan results. |
WifiNetworkSpecifier.Builder
|
setBssidPattern(MacAddress baseAddress, MacAddress mask)
Set the BSSID match pattern to use for filtering networks from scan results. |
WifiNetworkSpecifier.Builder
|
setIsEnhancedOpen(boolean isEnhancedOpen)
Specifies whether this represents an Enhanced Open (OWE) network. |
WifiNetworkSpecifier.Builder
|
setIsHiddenSsid(boolean isHiddenSsid)
Specifies whether this represents a hidden network. |
WifiNetworkSpecifier.Builder
|
setSsid(String ssid)
Set the unicode SSID for the network. |
WifiNetworkSpecifier.Builder
|
setSsidPattern(PatternMatcher ssidPattern)
Set the unicode SSID match pattern to use for filtering networks from scan results. |
WifiNetworkSpecifier.Builder
|
setWpa2EnterpriseConfig(WifiEnterpriseConfig enterpriseConfig)
Set the associated enterprise configuration for this network. |
WifiNetworkSpecifier.Builder
|
setWpa2Passphrase(String passphrase)
Set the ASCII WPA2 passphrase for this network. |
WifiNetworkSpecifier.Builder
|
setWpa3EnterpriseConfig(WifiEnterpriseConfig enterpriseConfig)
Set the associated enterprise configuration for this network. |
WifiNetworkSpecifier.Builder
|
setWpa3Passphrase(String passphrase)
Set the ASCII WPA3 passphrase for this network. |
Inherited methods | |
---|---|
public Builder ()
public WifiNetworkSpecifier build ()
Create a specifier object used to request a local Wi-Fi network. The generated
NetworkSpecifier
should be used in
NetworkRequest.Builder#setNetworkSpecifier(NetworkSpecifier)
when building
the NetworkRequest
. These specifiers can only be used to request a local wifi
network (i.e no internet capability). So, the device will not switch it's default route
to wifi if there are other transports (cellular for example) available.
Note: Apps can set a combination of network match params:
setSsidPattern(android.os.PatternMatcher)
OR Specific SSID using
setSsid(java.lang.String)
. setBssidPattern(android.net.MacAddress, android.net.MacAddress)
OR Specific
BSSID using setBssid(android.net.MacAddress)
final NetworkSpecifier specifier =
new Builder()
.setSsidPattern(new PatternMatcher("test", PatterMatcher.PATTERN_PREFIX))
.setBssidPattern(MacAddress.fromString("10:03:23:00:00:00"),
MacAddress.fromString("ff:ff:ff:00:00:00"))
.build()
final NetworkRequest request =
new NetworkRequest.Builder()
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
.removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
.setNetworkSpecifier(specifier)
.build();
final ConnectivityManager connectivityManager =
context.getSystemService(Context.CONNECTIVITY_SERVICE);
final NetworkCallback networkCallback = new NetworkCallback() {
...
{@literal @}Override
void onAvailable(...) {}
// etc.
};
connectivityManager.requestNetwork(request, networkCallback);
Returns | |
---|---|
WifiNetworkSpecifier |
Instance of NetworkSpecifier .
This value cannot be null . |
Throws | |
---|---|
IllegalStateException |
on invalid params set. |
public WifiNetworkSpecifier.Builder setBssid (MacAddress bssid)
Set the BSSID to use for filtering networks from scan results. Will only match network whose BSSID is identical to the specified value.
setBssid(android.net.MacAddress)
or
setBssidPattern(android.net.MacAddress, android.net.MacAddress)
.Parameters | |
---|---|
bssid |
MacAddress : BSSID of the network.
This value cannot be null . |
Returns | |
---|---|
WifiNetworkSpecifier.Builder |
Instance of Builder to enable chaining of the builder method.
This value cannot be null . |
public WifiNetworkSpecifier.Builder setBssidPattern (MacAddress baseAddress, MacAddress mask)
Set the BSSID match pattern to use for filtering networks from scan results.
Will match all networks with BSSID which satisfies the following:
BSSID & mask == baseAddress
.
setBssid(android.net.MacAddress)
or
setBssidPattern(android.net.MacAddress, android.net.MacAddress)
.Parameters | |
---|---|
baseAddress |
MacAddress : Base address for BSSID pattern.
This value cannot be null . |
mask |
MacAddress : Mask for BSSID pattern.
This value cannot be null . |
Returns | |
---|---|
WifiNetworkSpecifier.Builder |
Instance of Builder to enable chaining of the builder method.
This value cannot be null . |
public WifiNetworkSpecifier.Builder setIsEnhancedOpen (boolean isEnhancedOpen)
Specifies whether this represents an Enhanced Open (OWE) network.
Parameters | |
---|---|
isEnhancedOpen |
boolean : true to indicate that the network uses enhanced open,
false otherwise. |
Returns | |
---|---|
WifiNetworkSpecifier.Builder |
Instance of Builder to enable chaining of the builder method.
This value cannot be null . |
public WifiNetworkSpecifier.Builder setIsHiddenSsid (boolean isHiddenSsid)
Specifies whether this represents a hidden network.
setSsidPattern(android.os.PatternMatcher)
since
hidden networks need to be explicitly probed for.Parameters | |
---|---|
isHiddenSsid |
boolean : true to indicate that the network is hidden, false
otherwise. |
Returns | |
---|---|
WifiNetworkSpecifier.Builder |
Instance of Builder to enable chaining of the builder method.
This value cannot be null . |
public WifiNetworkSpecifier.Builder setSsid (String ssid)
Set the unicode SSID for the network.
setSsid(java.lang.String)
or
setSsidPattern(android.os.PatternMatcher)
.Parameters | |
---|---|
ssid |
String : The SSID of the network. It must be valid Unicode.
This value cannot be null . |
Returns | |
---|---|
WifiNetworkSpecifier.Builder |
Instance of Builder to enable chaining of the builder method.
This value cannot be null . |
Throws | |
---|---|
IllegalArgumentException |
if the SSID is not valid unicode. |
public WifiNetworkSpecifier.Builder setSsidPattern (PatternMatcher ssidPattern)
Set the unicode SSID match pattern to use for filtering networks from scan results.
setSsid(java.lang.String)
or
setSsidPattern(android.os.PatternMatcher)
.Parameters | |
---|---|
ssidPattern |
PatternMatcher : Instance of PatternMatcher containing the UTF-8 encoded
string pattern to use for matching the network's SSID.
This value cannot be null . |
Returns | |
---|---|
WifiNetworkSpecifier.Builder |
Instance of Builder to enable chaining of the builder method.
This value cannot be null . |
public WifiNetworkSpecifier.Builder setWpa2EnterpriseConfig (WifiEnterpriseConfig enterpriseConfig)
Set the associated enterprise configuration for this network. Needed for authenticating
to WPA2-EAP networks. See WifiEnterpriseConfig
for description.
Parameters | |
---|---|
enterpriseConfig |
WifiEnterpriseConfig : Instance of WifiEnterpriseConfig .
This value cannot be null . |
Returns | |
---|---|
WifiNetworkSpecifier.Builder |
Instance of Builder to enable chaining of the builder method.
This value cannot be null . |
public WifiNetworkSpecifier.Builder setWpa2Passphrase (String passphrase)
Set the ASCII WPA2 passphrase for this network. Needed for authenticating to WPA2-PSK networks.
Parameters | |
---|---|
passphrase |
String : passphrase of the network.
This value cannot be null . |
Returns | |
---|---|
WifiNetworkSpecifier.Builder |
Instance of Builder to enable chaining of the builder method.
This value cannot be null . |
Throws | |
---|---|
IllegalArgumentException |
if the passphrase is not ASCII encodable. |
public WifiNetworkSpecifier.Builder setWpa3EnterpriseConfig (WifiEnterpriseConfig enterpriseConfig)
Set the associated enterprise configuration for this network. Needed for authenticating
to WPA3-Enterprise networks (standard and 192-bit security). See
WifiEnterpriseConfig
for description. For 192-bit security networks, both the
client and CA certificates must be provided, and must be of type of either
sha384WithRSAEncryption (OID 1.2.840.113549.1.1.12) or ecdsa-with-SHA384
(OID 1.2.840.10045.4.3.3).
Parameters | |
---|---|
enterpriseConfig |
WifiEnterpriseConfig : Instance of WifiEnterpriseConfig .
This value cannot be null . |
Returns | |
---|---|
WifiNetworkSpecifier.Builder |
Instance of Builder to enable chaining of the builder method.
This value cannot be null . |
public WifiNetworkSpecifier.Builder setWpa3Passphrase (String passphrase)
Set the ASCII WPA3 passphrase for this network. Needed for authenticating to WPA3-SAE networks.
Parameters | |
---|---|
passphrase |
String : passphrase of the network.
This value cannot be null . |
Returns | |
---|---|
WifiNetworkSpecifier.Builder |
Instance of Builder to enable chaining of the builder method.
This value cannot be null . |
Throws | |
---|---|
IllegalArgumentException |
if the passphrase is not ASCII encodable. |