# SoftApConfiguration.Builder

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

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/net/wifi/SoftApConfiguration.Builder "View this page in Java")  

```
class Builder
```

|---|----------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                               ||
| ↳ | [android.net.wifi.SoftApConfiguration.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration.Builder#) |

Builds a[SoftApConfiguration](https://developer.android.com/reference/kotlin/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                                                                                                                               ||
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration.Builder#Builder())`()` Constructs a Builder with default values (see[Builder](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration.Builder#)). |

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

## Public constructors

### Builder

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

```
Builder()
```

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

## Public methods

### build

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

```
fun build(): SoftApConfiguration
```

Builds the[SoftApConfiguration](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration).

|                                                                                                                                              Return                                                                                                                                              ||
|------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [SoftApConfiguration](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration) | A new[SoftApConfiguration](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration), as configured by previous method calls. This value cannot be`null`. |

### setBssid

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

```
fun setBssid(bssid: MacAddress?): SoftApConfiguration.Builder
```

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 #RANDOMIZATION_NONE. See #setMacRandomizationSetting(int) for details. If multiple bands are requested via #setBands(int\[\]) or[setChannels(android.util.SparseIntArray)](https://developer.android.com/reference/kotlin/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 android.net.wifi.WifiManager.SoftApCallback#onCapabilityChanged(android.net.wifi.SoftApCapability) and[SoftApCapability.areFeaturesSupported(long)](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration.Builder#)with SoftApCapability.SOFTAP_FEATURE_MAC_ADDRESS_CUSTOMIZATION 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[TetheringManager.startTethering](https://developer.android.com/reference/kotlin/android/net/TetheringManager.html#startTethering(android.net.TetheringManager.TetheringRequest,%20java.util.concurrent.Executor,%20android.net.TetheringManager.StartTetheringCallback))are exempted from this permission restriction.

|                                                                                                    Parameters                                                                                                    ||
|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `bssid` | [MacAddress](https://developer.android.com/reference/kotlin/android/net/MacAddress.html#)?:BSSID, or null to have the BSSID chosen by the framework. The caller is responsible for avoiding collisions. |

|                                                                       Return                                                                       ||
|-----------------------------------------------------------------------------------------------------------------------------|-----------------------|
| [SoftApConfiguration.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration.Builder#) | Builder for chaining. |

|                                                   Exceptions                                                    ||
|--------------------------------------|---------------------------------------------------------------------------|
| `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.html#ApiLevels)  

```
fun setChannels(channels: SparseIntArray): SoftApConfiguration.Builder
```

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[WifiManager.isBridgedApConcurrencySupported()](https://developer.android.com/reference/kotlin/android/net/wifi/WifiManager#isBridgedApConcurrencySupported())to determine whether concurrent APs are supported. If not set, the default value is[BAND_2GHZ](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration#BAND_2GHZ:kotlin.Int)with the special channel value 0 which has the framework auto-select from[BAND_2GHZ](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration#BAND_2GHZ:kotlin.Int).

<br />

|                                                                                                               Parameters                                                                                                                ||
|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `channels` | [SparseIntArray](https://developer.android.com/reference/kotlin/android/util/SparseIntArray.html#):SparseIntArray (key:`BandType`, value: channel) consists of`BAND_`and corresponding channel. This value cannot be`null`. |

|                                                                                     Return                                                                                     ||
|-----------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------|
| [SoftApConfiguration.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration.Builder#) | Builder for chaining. This value cannot be`null`. |

|                                                         Exceptions                                                         ||
|--------------------------------------|--------------------------------------------------------------------------------------|
| `java.lang.IllegalArgumentException` | when more than 2 channels are set or the invalid channel or band type is configured. |

### setPassphrase

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

```
fun setPassphrase(
    passphrase: String?, 
    securityType: Int
): SoftApConfiguration.Builder
```

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

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ||
|----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `securityType` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):One of the following security types:[SECURITY_TYPE_OPEN](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_OPEN:kotlin.Int),[SECURITY_TYPE_WPA2_PSK](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA2_PSK:kotlin.Int),[SECURITY_TYPE_WPA3_SAE_TRANSITION](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_SAE_TRANSITION:kotlin.Int),[SECURITY_TYPE_WPA3_SAE](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_SAE:kotlin.Int),[SECURITY_TYPE_WPA3_OWE_TRANSITION](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_OWE_TRANSITION:kotlin.Int),[SECURITY_TYPE_WPA3_OWE](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_OWE:kotlin.Int). Value is[android.net.wifi.SoftApConfiguration#SECURITY_TYPE_OPEN](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_OPEN:kotlin.Int),[android.net.wifi.SoftApConfiguration#SECURITY_TYPE_WPA2_PSK](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA2_PSK:kotlin.Int),[android.net.wifi.SoftApConfiguration#SECURITY_TYPE_WPA3_SAE_TRANSITION](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_SAE_TRANSITION:kotlin.Int),[android.net.wifi.SoftApConfiguration#SECURITY_TYPE_WPA3_SAE](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_SAE:kotlin.Int),[android.net.wifi.SoftApConfiguration#SECURITY_TYPE_WPA3_OWE_TRANSITION](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_OWE_TRANSITION:kotlin.Int), or[android.net.wifi.SoftApConfiguration#SECURITY_TYPE_WPA3_OWE](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_OWE:kotlin.Int) |
| `passphrase`   | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)?:The passphrase to use for sepcific`securityType`configuration or null with[SECURITY_TYPE_OPEN](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_OPEN:kotlin.Int),[SECURITY_TYPE_WPA3_OWE_TRANSITION](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_OWE_TRANSITION:kotlin.Int), and[SECURITY_TYPE_WPA3_OWE](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_OWE:kotlin.Int).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

|                                                                                     Return                                                                                     ||
|-----------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------|
| [SoftApConfiguration.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration.Builder#) | Builder for chaining. This value cannot be`null`. |

|                                                                                                                                                                                                                                                                                       Exceptions                                                                                                                                                                                                                                                                                        ||
|--------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java.lang.IllegalArgumentException` | before[android.os.Build.VERSION_CODES#TIRAMISU](https://developer.android.com/reference/kotlin/android/os/Build.VERSION_CODES.html#TIRAMISU:kotlin.Int)) when the passphrase is not between 8 and 63 bytes (inclusive) for -[SECURITY_TYPE_WPA2_PSK](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA2_PSK:kotlin.Int)-[SECURITY_TYPE_WPA3_SAE_TRANSITION](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration#SECURITY_TYPE_WPA3_SAE_TRANSITION:kotlin.Int) |

### setWifiSsid

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

```
fun setWifiSsid(wifiSsid: WifiSsid?): SoftApConfiguration.Builder
```

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](https://developer.android.com/reference/kotlin/android/net/wifi/WifiSsid)?:SSID, or null ot have the SSID automatically chosen by the framework. |

|                                                                       Return                                                                       ||
|-----------------------------------------------------------------------------------------------------------------------------|-----------------------|
| [SoftApConfiguration.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/SoftApConfiguration.Builder#) | Builder for chaining. |