# Print output for @column tags ?>
Developers

- Design
- Develop
- Distribute

Developer Console

## Most visited

## Recently visited

## Results for

Summary: Ctors | Methods | Inherited Methods

# WifiNetworkSuggestion.Builder

`public static final class WifiNetworkSuggestion.Builder`
`extends Object` ``

java.lang.Object
↳ | android.net.wifi.WifiNetworkSuggestion.Builder

Builder used to create `WifiNetworkSuggestion` objects.

## Summary

### Public constructors
`Builder()`

### Public methods
`WifiNetworkSuggestion` | `build()` Create a network suggestion object for use in `WifiManager#addNetworkSuggestions(List)`.
`WifiNetworkSuggestion.Builder` | `setBssid(MacAddress bssid)` Set the BSSID to use for filtering networks from scan results.
`WifiNetworkSuggestion.Builder` | `setCredentialSharedWithUser(boolean isShared)` Specifies whether the network credentials provided with this suggestion can be used by the user to explicitly (manually) connect to this network.
`WifiNetworkSuggestion.Builder` | `setIsAppInteractionRequired(boolean isAppInteractionRequired)` Specifies whether the app needs to log in to a captive portal to obtain Internet access.
`WifiNetworkSuggestion.Builder` | `setIsEnhancedOpen(boolean isEnhancedOpen)` Specifies whether this represents an Enhanced Open (OWE) network.
`WifiNetworkSuggestion.Builder` | `setIsHiddenSsid(boolean isHiddenSsid)` Specifies whether this represents a hidden network.
`WifiNetworkSuggestion.Builder` | `setIsInitialAutojoinEnabled(boolean enabled)` Specifies whether the suggestion is created with auto-join enabled or disabled.
`WifiNetworkSuggestion.Builder` | `setIsMetered(boolean isMetered)` Specifies whether this network is metered.
`WifiNetworkSuggestion.Builder` | `setIsUserInteractionRequired(boolean isUserInteractionRequired)` Specifies whether the user needs to log in to a captive portal to obtain Internet access.
`WifiNetworkSuggestion.Builder` | `setPasspointConfig(PasspointConfiguration passpointConfig)` Set the associated Passpoint configuration for this network.
`WifiNetworkSuggestion.Builder` | `setPriority(int priority)` Specify the priority of this network among other network suggestions provided by the same app (priorities have no impact on suggestions by different apps).
`WifiNetworkSuggestion.Builder` | `setSsid(String ssid)` Set the unicode SSID for the network.
`WifiNetworkSuggestion.Builder` | `setUntrusted(boolean isUntrusted)` Specifies whether the system will bring up the network (if selected) as untrusted.
`WifiNetworkSuggestion.Builder` | `setWapiEnterpriseConfig(WifiEnterpriseConfig enterpriseConfig)` Set the associated enterprise configuration for this network.
`WifiNetworkSuggestion.Builder` | `setWapiPassphrase(String passphrase)` Set the ASCII WAPI passphrase for this network.
`WifiNetworkSuggestion.Builder` | `setWpa2EnterpriseConfig(WifiEnterpriseConfig enterpriseConfig)` Set the associated enterprise configuration for this network.
`WifiNetworkSuggestion.Builder` | `setWpa2Passphrase(String passphrase)` Set the ASCII WPA2 passphrase for this network.
`WifiNetworkSuggestion.Builder` | `setWpa3EnterpriseConfig(WifiEnterpriseConfig enterpriseConfig)` Set the associated enterprise configuration for this network.
`WifiNetworkSuggestion.Builder` | `setWpa3Passphrase(String passphrase)` Set the ASCII WPA3 passphrase for this network.

### Inherited methods
From class `java.lang.Object`
`Object` | `clone()` Creates and returns a copy of this object.
`boolean` | `equals(Object obj)` Indicates whether some other object is "equal to" this one.
`void` | `finalize()` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
`final Class<?>` | `getClass()` Returns the runtime class of this `Object`.
`int` | `hashCode()` Returns a hash code value for the object.
`final void` | `notify()` Wakes up a single thread that is waiting on this object's monitor.
`final void` | `notifyAll()` Wakes up all threads that are waiting on this object's monitor.
`String` | `toString()` Returns a string representation of the object.
`final void` | `wait(long timeout, int nanos)` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
`final void` | `wait(long timeout)` Causes the current thread to wait until either another thread invokes the `notify()` method or the `notifyAll()` method for this object, or a specified amount of time has elapsed.
`final void` | `wait()` Causes the current thread to wait until another thread invokes the `notify()` method or the `notifyAll()` method for this object.

## Public constructors

### Builder

    public Builder ()

## Public methods

### build

    public WifiNetworkSuggestion build ()

Create a network suggestion object for use in `WifiManager#addNetworkSuggestions(List)`.

Note: Apps can set a combination of SSID using `setSsid(java.lang.String)` and BSSID using `setBssid(android.net.MacAddress)` to provide more fine grained network suggestions to the platform.

For example: To provide credentials for one open, one WPA2, one WPA3 network with their corresponding SSID's and one with Passpoint config:

    final WifiNetworkSuggestion suggestion1 =
          new Builder()
          .setSsid("test111111")
          .build();
     final WifiNetworkSuggestion suggestion2 =
          new Builder()
          .setSsid("test222222")
          .setWpa2Passphrase("test123456")
          .build();
     final WifiNetworkSuggestion suggestion3 =
          new Builder()
          .setSsid("test333333")
          .setWpa3Passphrase("test6789")
          .build();
     final PasspointConfiguration passpointConfig= new PasspointConfiguration();
     // configure passpointConfig to include a valid Passpoint configuration
     final WifiNetworkSuggestion suggestion4 =
          new Builder()
          .setPasspointConfig(passpointConfig)
          .build();
     final List<WifiNetworkSuggestion> suggestionsList =
          new ArrayList<WifiNetworkSuggestion> { {
              add(suggestion1);
              add(suggestion2);
              add(suggestion3);
              add(suggestion4);
          } };
     final WifiManager wifiManager =
          context.getSystemService(Context.WIFI_SERVICE);
     wifiManager.addNetworkSuggestions(suggestionsList);
     // ...

Returns
`WifiNetworkSuggestion` | Instance of `WifiNetworkSuggestion` This value cannot be `null`.

Throws
`IllegalStateException` | on invalid params set

See also:

- `WifiNetworkSuggestion`

### setBssid

    public WifiNetworkSuggestion.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.

- If set, only the specified BSSID with the specified SSID will be considered for connection.
- If not set, all BSSIDs with the specified SSID will be considered for connection.
- Overrides any previous value set using `setBssid(android.net.MacAddress)`.

Parameters
`bssid` | `MacAddress`: BSSID of the network. This value cannot be `null`.

Returns
`WifiNetworkSuggestion.Builder` | Instance of `Builder` to enable chaining of the builder method. This value cannot be `null`.

### setCredentialSharedWithUser

    public WifiNetworkSuggestion.Builder setCredentialSharedWithUser (boolean isShared)

Specifies whether the network credentials provided with this suggestion can be used by the user to explicitly (manually) connect to this network. If true this network will appear in the Wi-Fi Picker (in Settings) and the user will be able to select and connect to it with the provided credentials. If false, the user will need to enter network credentials and the resulting configuration will become a user saved network.

- Note: Only valid for secure (non-open) networks.
- If not set, defaults to true (i.e. allow user to manually connect) for secure networks and false for open networks.

Parameters
`isShared` | `boolean`: `true` to indicate that the credentials may be used by the user to manually connect to the network, `false` otherwise.

Returns
`WifiNetworkSuggestion.Builder` | Instance of `Builder` to enable chaining of the builder method. This value cannot be `null`.

### setIsAppInteractionRequired

    public WifiNetworkSuggestion.Builder setIsAppInteractionRequired (boolean isAppInteractionRequired)

Specifies whether the app needs to log in to a captive portal to obtain Internet access.

This will dictate if the directed broadcast `WifiManager#ACTION_WIFI_NETWORK_SUGGESTION_POST_CONNECTION` will be sent to the app after successfully connecting to the network. Use this for captive portal type networks where the app needs to authenticate the user before the device can access the network.

- If not set, defaults to false (i.e no app interaction required).

Parameters
`isAppInteractionRequired` | `boolean`: `true` to indicate that app interaction is required, `false` otherwise.

Returns
`WifiNetworkSuggestion.Builder` | Instance of `Builder` to enable chaining of the builder method. This value cannot be `null`.

### setIsEnhancedOpen

    public WifiNetworkSuggestion.Builder setIsEnhancedOpen (boolean isEnhancedOpen)

Specifies whether this represents an Enhanced Open (OWE) network.

Parameters
`isEnhancedOpen` | `boolean`: `true` to indicate that the network used enhanced open, `false` otherwise.

Returns
`WifiNetworkSuggestion.Builder` | Instance of `Builder` to enable chaining of the builder method. This value cannot be `null`.

### setIsHiddenSsid

    public WifiNetworkSuggestion.Builder setIsHiddenSsid (boolean isHiddenSsid)

Specifies whether this represents a hidden network.

- If not set, defaults to false (i.e not a hidden network).

Parameters
`isHiddenSsid` | `boolean`: `true` to indicate that the network is hidden, `false` otherwise.

Returns
`WifiNetworkSuggestion.Builder` | Instance of `Builder` to enable chaining of the builder method. This value cannot be `null`.

### setIsInitialAutojoinEnabled

    public WifiNetworkSuggestion.Builder setIsInitialAutojoinEnabled (boolean enabled)

Specifies whether the suggestion is created with auto-join enabled or disabled. The user may modify the auto-join configuration of a suggestion directly once the device associates to the network.

If auto-join is initialized as disabled the user may still be able to manually connect to the network. Therefore, disabling auto-join only makes sense if `setCredentialSharedWithUser(boolean)` is set to true (the default) which itself implies a secure (non-open) network.

If not set, defaults to true (i.e. auto-join is initialized as enabled).

Parameters
`enabled` | `boolean`: true for initializing with auto-join enabled (the default), false to initializing with auto-join disabled.

Returns
`WifiNetworkSuggestion.Builder` | Instance of `Builder` to enable chaining of the builder method. This value cannot be `null`.

### setIsMetered

    public WifiNetworkSuggestion.Builder setIsMetered (boolean isMetered)

Specifies whether this network is metered.

- If not set, defaults to detect automatically.

Parameters
`isMetered` | `boolean`: `true` to indicate that the network is metered, `false` for not metered.

Returns
`WifiNetworkSuggestion.Builder` | Instance of `Builder` to enable chaining of the builder method. This value cannot be `null`.

### setIsUserInteractionRequired

    public WifiNetworkSuggestion.Builder setIsUserInteractionRequired (boolean isUserInteractionRequired)

Specifies whether the user needs to log in to a captive portal to obtain Internet access.

- If not set, defaults to false (i.e no user interaction required).

Parameters
`isUserInteractionRequired` | `boolean`: `true` to indicate that user interaction is required, `false` otherwise.

Returns
`WifiNetworkSuggestion.Builder` | Instance of `Builder` to enable chaining of the builder method. This value cannot be `null`.

### setPasspointConfig

    public WifiNetworkSuggestion.Builder setPasspointConfig (PasspointConfiguration passpointConfig)

Set the associated Passpoint configuration for this network. Needed for authenticating to Hotspot 2.0 networks. See `PasspointConfiguration` for description.

Parameters
`passpointConfig` | `PasspointConfiguration`: Instance of `PasspointConfiguration`. This value cannot be `null`.

Returns
`WifiNetworkSuggestion.Builder` | Instance of `Builder` to enable chaining of the builder method. This value cannot be `null`.

Throws
`IllegalArgumentException` | if passpoint configuration is invalid.

### setPriority

    public WifiNetworkSuggestion.Builder setPriority (int priority)

Specify the priority of this network among other network suggestions provided by the same app (priorities have no impact on suggestions by different apps). The higher the number, the higher the priority (i.e value of 0 = lowest priority).

- If not set, defaults a lower priority than any assigned priority.

Parameters
`priority` | `int`: Integer number representing the priority among suggestions by the app. Value is 0 or greater

Returns
`WifiNetworkSuggestion.Builder` | Instance of `Builder` to enable chaining of the builder method. This value cannot be `null`.

Throws
`IllegalArgumentException` | if the priority value is negative.

### setSsid

    public WifiNetworkSuggestion.Builder setSsid (String ssid)

Set the unicode SSID for the network.

- Overrides any previous value set using `setSsid(java.lang.String)`.

Parameters
`ssid` | `String`: The SSID of the network. It must be valid Unicode. This value cannot be `null`.

Returns
`WifiNetworkSuggestion.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.

### setUntrusted

    public WifiNetworkSuggestion.Builder setUntrusted (boolean isUntrusted)

Specifies whether the system will bring up the network (if selected) as untrusted. An untrusted network has its `NetworkCapabilities.NET_CAPABILITY_TRUSTED` capability removed. The Wi-Fi network selection process may use this information to influence priority of the suggested network for Wi-Fi network selection (most likely to reduce it). The connectivity service may use this information to influence the overall network configuration of the device.

- An untrusted network's credentials may not be shared with the user using `setCredentialSharedWithUser(boolean)`.
- If not set, defaults to false (i.e. network is trusted).

Parameters
`isUntrusted` | `boolean`: Boolean indicating whether the network should be brought up untrusted (if true) or trusted (if false).

Returns
`WifiNetworkSuggestion.Builder` | Instance of `Builder` to enable chaining of the builder method. This value cannot be `null`.

### setWapiEnterpriseConfig

    public WifiNetworkSuggestion.Builder setWapiEnterpriseConfig (WifiEnterpriseConfig enterpriseConfig)

Set the associated enterprise configuration for this network. Needed for authenticating to WAPI-CERT networks. See `WifiEnterpriseConfig` for description.

Parameters
`enterpriseConfig` | `WifiEnterpriseConfig`: Instance of `WifiEnterpriseConfig`. This value cannot be `null`.

Returns
`WifiNetworkSuggestion.Builder` | Instance of `Builder` to enable chaining of the builder method. This value cannot be `null`.

### setWapiPassphrase

    public WifiNetworkSuggestion.Builder setWapiPassphrase (String passphrase)

Set the ASCII WAPI passphrase for this network. Needed for authenticating to WAPI-PSK networks.

Parameters
`passphrase` | `String`: passphrase of the network. This value cannot be `null`.

Returns
`WifiNetworkSuggestion.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.

### setWpa2EnterpriseConfig

    public WifiNetworkSuggestion.Builder setWpa2EnterpriseConfig (WifiEnterpriseConfig enterpriseConfig)

Set the associated enterprise configuration for this network. Needed for authenticating to WPA2 enterprise networks. See `WifiEnterpriseConfig` for description.

Parameters
`enterpriseConfig` | `WifiEnterpriseConfig`: Instance of `WifiEnterpriseConfig`. This value cannot be `null`.

Returns
`WifiNetworkSuggestion.Builder` | Instance of `Builder` to enable chaining of the builder method. This value cannot be `null`.

Throws
`IllegalArgumentException` | if configuration CA certificate or AltSubjectMatch/DomainSuffixMatch is not set.

### setWpa2Passphrase

    public WifiNetworkSuggestion.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
`WifiNetworkSuggestion.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.

### setWpa3EnterpriseConfig

    public WifiNetworkSuggestion.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
`WifiNetworkSuggestion.Builder` | Instance of `Builder` to enable chaining of the builder method. This value cannot be `null`.

Throws
`IllegalArgumentException` | if configuration CA certificate or AltSubjectMatch/DomainSuffixMatch is not set.

### setWpa3Passphrase

    public WifiNetworkSuggestion.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
`WifiNetworkSuggestion.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.

Full name *
Email address *
Company / developer name
One of your Play Store app URLs *
Which best describes your business:*
Apps
Games
Apps & Games
*
*