Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/net/wifi/SoftApConfiguration.Builder#pubctors) \| [Methods](https://developer.android.com/reference/android/net/wifi/SoftApConfiguration.Builder#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/net/wifi/SoftApConfiguration.Builder#inhmethods)

# SoftApConfiguration.Builder

*** ** * ** ***

` public static final class SoftApConfiguration.Builder `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.net.wifi.SoftApConfiguration.Builder |

<br />

*** ** * ** ***

Builds a `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration`, which allows an app to configure various aspects of a Soft AP. All fields are optional. By default, SSID and BSSID are automatically chosen by the framework, and an open network is created.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/net/wifi/SoftApConfiguration.Builder#Builder()() ` Constructs a Builder with default values (see `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration.Builder`). |

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/net/wifi/SoftApConfiguration` | ` https://developer.android.com/reference/android/net/wifi/SoftApConfiguration.Builder#build()() ` Builds the `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration`. |
| ` https://developer.android.com/reference/android/net/wifi/SoftApConfiguration.Builder` | ` https://developer.android.com/reference/android/net/wifi/SoftApConfiguration.Builder#setBssid(android.net.MacAddress)(https://developer.android.com/reference/android/net/MacAddress bssid) ` Specifies a BSSID for the AP. |
| ` https://developer.android.com/reference/android/net/wifi/SoftApConfiguration.Builder` | ` https://developer.android.com/reference/android/net/wifi/SoftApConfiguration.Builder#setChannels(android.util.SparseIntArray)(https://developer.android.com/reference/android/util/SparseIntArray channels) ` Specifies the channels and associated bands for the APs. |
| ` https://developer.android.com/reference/android/net/wifi/SoftApConfiguration.Builder` | ` https://developer.android.com/reference/android/net/wifi/SoftApConfiguration.Builder#setPassphrase(java.lang.String,%20int)(https://developer.android.com/reference/java/lang/String passphrase, int securityType) ` Specifies that this AP should use specific security type with the given ASCII passphrase. |
| ` https://developer.android.com/reference/android/net/wifi/SoftApConfiguration.Builder` | ` https://developer.android.com/reference/android/net/wifi/SoftApConfiguration.Builder#setWifiSsid(android.net.wifi.WifiSsid)(https://developer.android.com/reference/android/net/wifi/WifiSsid wifiSsid) ` Specifies an SSID for the AP in the form of WifiSsid. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### Builder

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Builder ()
```

Constructs a Builder with default values (see `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration.Builder`).

<br />

## Public methods

### build

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SoftApConfiguration build ()
```

Builds the `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration` | A new `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration`, as configured by previous method calls. This value cannot be `null`. <br /> |

### setBssid

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)

```
public SoftApConfiguration.Builder setBssid (MacAddress bssid)
```

Specifies a BSSID for the AP.

<br />

- If not set, defaults to null.
When this method is called, the caller needs to configure MAC randomization settings to `https://developer.android.com/`. See `https://developer.android.com/` for details. If multiple bands are requested via `https://developer.android.com/` or `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration.Builder#setChannels(android.util.SparseIntArray)`, HAL will derive 2 MAC addresses since framework only sends down 1 MAC address. An example (but different implementation may perform a different mapping):
- MAC address 1: copy value of MAC address, and set byte 1 = (0xFF - BSSID\[1\])
- MAC address 2: copy value of MAC address, and set byte 2 = (0xFF - BSSID\[2\])
Example BSSID argument: e2:38:60:c4:0e:b7 Derived MAC address 1: e2:c7:60:c4:0e:b7 Derived MAC address 2: e2:38:9f:c4:0e:b7
- Use `https://developer.android.com/` and `https://developer.android.com/` with `https://developer.android.com/` to determine whether or not this feature is supported.
- Callers without the listed permissions will not be able to start SoftAP with a non-null BSSID. DO and Carrier apps starting SoftAp with `https://developer.android.com/reference/android/net/TetheringManager#startTethering(android.net.TetheringManager.TetheringRequest,%20java.util.concurrent.Executor,%20android.net.TetheringManager.StartTetheringCallback)` are exempted from this permission restriction.

| Parameters ||
|---|---|
| `bssid` | `MacAddress`: BSSID, or null to have the BSSID chosen by the framework. The caller is responsible for avoiding collisions. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration.Builder` | Builder for chaining. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | when the given BSSID is the all-zero, multicast or broadcast MAC address. |

### setChannels

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public SoftApConfiguration.Builder setChannels (SparseIntArray channels)
```

Specifies the channels and associated bands for the APs.

The API contains (band, channel) input since the 6GHz band uses the same channel numbering scheme as is used in the 2.4GHz and 5GHz band. Therefore, both are needed to uniquely identify individual channels.

Reference the Wi-Fi channel numbering and the channelization in IEEE 802.11-2016 specifications, section 17.3.8.4.2, 17.3.8.4.3 and Table 15-6.

Using the special value 0 which has the framework auto-select a valid channel from the band configured. When more than 1 channel/band is set, this will bring up concurrent APs on the requested channels and bands (if possible). Use `https://developer.android.com/reference/android/net/wifi/WifiManager#isBridgedApConcurrencySupported()` to determine whether concurrent APs are supported. If not set, the default value is `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#BAND_2GHZ` with the special channel value 0 which has the framework auto-select from `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#BAND_2GHZ`.

<br />

<br />

| Parameters ||
|---|---|
| `channels` | `SparseIntArray`: SparseIntArray (key: `#BandType` , value: channel) consists of `BAND_` and corresponding channel. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration.Builder` | Builder for chaining. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | when more than 2 channels are set or the invalid channel or band type is configured. |

### setPassphrase

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)

```
public SoftApConfiguration.Builder setPassphrase (String passphrase, 
                int securityType)
```

Specifies that this AP should use specific security type with the given ASCII passphrase.

<br />

| Parameters ||
|---|---|
| `passphrase` | `String`: The passphrase to use for sepcific `securityType` configuration or null with `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_OPEN`, `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_OWE_TRANSITION`, and `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_OWE`. <br /> |
| `securityType` | `int`: One of the following security types: `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_OPEN`, `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA2_PSK`, `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_SAE_TRANSITION`, `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_SAE`, `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_OWE_TRANSITION`, `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_OWE`. Value is one of the following: - `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_OPEN` - `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA2_PSK` - `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_SAE_TRANSITION` - `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_SAE` - `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_OWE_TRANSITION` - `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_OWE` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration.Builder` | Builder for chaining. This value cannot be `null`. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | when the passphrase is non-null for - `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_OPEN` - `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_OWE_TRANSITION` - `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_OWE` |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | when the passphrase is empty for - `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA2_PSK`, - `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_SAE_TRANSITION`, - `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_SAE`, |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | before `https://developer.android.com/reference/android/os/Build.VERSION_CODES#TIRAMISU`) when the passphrase is not between 8 and 63 bytes (inclusive) for - `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA2_PSK` - `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_SAE_TRANSITION` |

### setWifiSsid

Added in [version 36.1](https://developer.android.com/topic/libraries/support-library/revisions)

```
public SoftApConfiguration.Builder setWifiSsid (WifiSsid wifiSsid)
```

Specifies an SSID for the AP in the form of WifiSsid.

Null SSID only support when configure a local-only hotspot.

<br />

- If not set, defaults to null.

| Parameters ||
|---|---|
| `wifiSsid` | `WifiSsid`: SSID, or null ot have the SSID automatically chosen by the framework. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/wifi/SoftApConfiguration.Builder` | Builder for chaining. <br /> |