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

# Builder

*** ** * ** ***

```
class Builder
```

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

Builder used to build `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig` objects.

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#Builder()()` Default constructor. |

| Public methods ||
|---|---|
| [PublishConfig](https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig)! | `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#build()()` Build `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig` given the current requests made on the builder. |
| [PublishConfig.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#) | `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#setDataPathSecurityConfig(android.net.wifi.aware.WifiAwareDataPathSecurityConfig)(securityConfig: https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig)` Configure security config for the Wi-Fi Aware publish session. |
| [PublishConfig.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#) | `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#setFrameworkOffloadedPairingEnabled(kotlin.Boolean)(enabled: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Configure whether to enable framework offloaded auto-pairing for this publish session. |
| [PublishConfig.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#) | `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#setInstantCommunicationModeEnabled(kotlin.Boolean,%20kotlin.Int)(enabled: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html, band: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Configure whether to enable and use instant communication for this publish session. |
| [PublishConfig.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#)! | `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#setMatchFilter(kotlin.collections.MutableList)(matchFilter: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html!>?)` The match filter for a publish session. |
| [PublishConfig.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#) | `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#setPairingConfig(android.net.wifi.aware.AwarePairingConfig)(config: https://developer.android.com/reference/kotlin/android/net/wifi/aware/AwarePairingConfig?)` Set the `https://developer.android.com/reference/kotlin/android/net/wifi/aware/AwarePairingConfig` for this publish session, the peer can use this info to determine the config of the following bootstrapping, pairing setup/verification request. |
| [PublishConfig.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#)! | `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#setPublishType(kotlin.Int)(publishType: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Specify the type of the publish session: solicited (aka active - publish packets are transmitted over-the-air), or unsolicited (aka passive - no publish packets are transmitted, a match is made against an active subscribe session whose packets are transmitted over-the-air). |
| [PublishConfig.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#)! | `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#setRangingEnabled(kotlin.Boolean)(enable: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Configure whether the publish discovery session supports ranging and allows peers to measure distance to it. |
| [PublishConfig.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#)! | `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#setServiceName(kotlin.String)(serviceName: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Specify the service name of the publish session. |
| [PublishConfig.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#)! | `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#setServiceSpecificInfo(kotlin.ByteArray)(serviceSpecificInfo: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html?)` Specify service specific information for the publish session. |
| [PublishConfig.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#)! | `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#setTerminateNotificationEnabled(kotlin.Boolean)(enable: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)` Configure whether a publish terminate notification `https://developer.android.com/reference/kotlin/android/net/wifi/aware/DiscoverySessionCallback#onSessionTerminated()` is reported back to the callback. |
| [PublishConfig.Builder](https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#)! | `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#setTtlSec(kotlin.Int)(ttlSec: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets the time interval (in seconds) an unsolicited ( `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#setPublishType(kotlin.Int)`) publish session will be alive - broadcasting a packet. |

## Public constructors

### Builder

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

```
Builder()
```

Default constructor.

## Public methods

### build

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

```
fun build(): PublishConfig!
```

Build `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig` given the current requests made on the builder.

### setDataPathSecurityConfig

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

```
fun setDataPathSecurityConfig(securityConfig: WifiAwareDataPathSecurityConfig): PublishConfig.Builder
```

Configure security config for the Wi-Fi Aware publish session. The security config set here must be the same as the one used to request Wi-Fi Aware data-path connection using `https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareNetworkSpecifier.Builder#setDataPathSecurityConfig(android.net.wifi.aware.WifiAwareDataPathSecurityConfig)`. This security config will create a security identifier (SCID) which contains a PMKID and transmitted in the publish message. The device which subscribe this session can get this info by `https://developer.android.com/reference/kotlin/android/net/wifi/aware/ServiceDiscoveryInfo#getScid()` This method is optional - if not called, then no security context identifier will be passed in the publish message, then no security context identifier will be provided in the `https://developer.android.com/reference/kotlin/android/net/wifi/aware/ServiceDiscoveryInfo` on the subscriber. Security can still be negotiated using out-of-band (OOB) mechanisms.

| Parameters ||
|---|---|
| `securityConfig` | [WifiAwareDataPathSecurityConfig](https://developer.android.com/reference/kotlin/android/net/wifi/aware/WifiAwareDataPathSecurityConfig): The (optional) security config to be used to create security context Identifier. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#` | the current `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#` builder, enabling chaining of builder methods. This value cannot be `null`. |

### setFrameworkOffloadedPairingEnabled

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

```
fun setFrameworkOffloadedPairingEnabled(enabled: Boolean): PublishConfig.Builder
```

Configure whether to enable framework offloaded auto-pairing for this publish session.

If this is enabled, the wifi framework will attempt to perform Wi-Fi Aware pairing automatically before starting the NAN datapath. When pairing happens for the first time, user authorization may be required (such as entering a pincode or password on the system UI).

As a result, apps are highly recommended to increase their connection timeout to at least 30 seconds when starting a datapath with this field enabled. Additionally, if the app is using framework offloaded pairing, the framework will override the `https://developer.android.com/reference/kotlin/android/net/wifi/aware/AwarePairingConfig` with a framework managed configuration.

| Parameters ||
|---|---|
| `enabled` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): If true, enable framework offloaded auto-pairing. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#` | the current `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#` builder, enabling chaining of builder methods. This value cannot be `null`. |

### setInstantCommunicationModeEnabled

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

```
fun setInstantCommunicationModeEnabled(
    enabled: Boolean, 
    band: Int
): PublishConfig.Builder
```

Configure whether to enable and use instant communication for this publish session. Instant communication will speed up service discovery and any data-path set up as part of this session. Use `https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#isInstantCommunicationModeSupported()` to check if the device supports this feature.

Note: due to increased power requirements of this mode - it will only remain enabled for 30 seconds from the time the discovery session is started.

| Parameters ||
|---|---|
| `enabled` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): true for enable instant communication mode, default is false. |
| `band` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): When setting to `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#WIFI_BAND_5_GHZ:kotlin.Int`, device will try to enable instant communication mode on 5Ghz, but may fall back to 2.4Ghz due to regulatory requirements. Value is one of the following: - `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#WIFI_BAND_24_GHZ:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/net/wifi/ScanResult.html#WIFI_BAND_5_GHZ:kotlin.Int` |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#` | the current `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#` builder, enabling chaining of builder methods. This value cannot be `null`. |

### setMatchFilter

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

```
fun setMatchFilter(matchFilter: MutableList<ByteArray!>?): PublishConfig.Builder!
```

The match filter for a publish session. Used to determine whether a service discovery occurred - in addition to relying on the service name.

Optional. Empty by default.

| Parameters ||
|---|---|
| `matchFilter` | [MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)!\>?: A list of match filter entries (each of which is an arbitrary byte array). This value may be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#!` | The builder to facilitate chaining `builder.setXXX(..).setXXX(..)`. |

### setPairingConfig

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

```
fun setPairingConfig(config: AwarePairingConfig?): PublishConfig.Builder
```

Set the `https://developer.android.com/reference/kotlin/android/net/wifi/aware/AwarePairingConfig` for this publish session, the peer can use this info to determine the config of the following bootstrapping, pairing setup/verification request.

| Parameters ||
|---|---|
| `config` | [AwarePairingConfig](https://developer.android.com/reference/kotlin/android/net/wifi/aware/AwarePairingConfig)?: The pairing config set to the peer. Only valid when `https://developer.android.com/reference/kotlin/android/net/wifi/aware/Characteristics#isAwarePairingSupported()` is true. This value may be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#` | the current `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#` builder, enabling chaining of builder methods. This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/net/wifi/aware/AwarePairingConfig`

### setPublishType

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

```
fun setPublishType(publishType: Int): PublishConfig.Builder!
```

Specify the type of the publish session: solicited (aka active - publish packets are transmitted over-the-air), or unsolicited (aka passive - no publish packets are transmitted, a match is made against an active subscribe session whose packets are transmitted over-the-air).

| Parameters ||
|---|---|
| `publishType` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Publish session type: `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig#PUBLISH_TYPE_SOLICITED:kotlin.Int` or `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig#PUBLISH_TYPE_UNSOLICITED:kotlin.Int` (the default). Value is one of the following: - `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig#PUBLISH_TYPE_UNSOLICITED:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig#PUBLISH_TYPE_SOLICITED:kotlin.Int` |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#!` | The builder to facilitate chaining `builder.setXXX(..).setXXX(..)`. |

### setRangingEnabled

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

```
fun setRangingEnabled(enable: Boolean): PublishConfig.Builder!
```

Configure whether the publish discovery session supports ranging and allows peers to measure distance to it. This API is used in conjunction with `https://developer.android.com/reference/kotlin/android/net/wifi/aware/SubscribeConfig.Builder#setEgressDistanceMm(kotlin.Int)` and `https://developer.android.com/reference/kotlin/android/net/wifi/aware/SubscribeConfig.Builder#setIngressDistanceMm(kotlin.Int)` to specify a minimum and/or maximum distance at which discovery will be triggered.

Optional. Disabled by default - i.e. any peer attempt to measure distance to this device will be refused and discovery will proceed without ranging constraints.

The device must support Wi-Fi RTT for this feature to be used. Feature support is checked as described in `https://developer.android.com/reference/kotlin/android/net/wifi/rtt/package-summary.html`.

| Parameters ||
|---|---|
| `enable` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): If true, ranging is supported on request of the peer. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#!` | The builder to facilitate chaining `builder.setXXX(..).setXXX(..)`. |

### setServiceName

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

```
fun setServiceName(serviceName: String): PublishConfig.Builder!
```

Specify the service name of the publish session. The actual on-air value is a 6 byte hashed representation of this string.

The Service Name is a UTF-8 encoded string from 1 to 255 bytes in length. The only acceptable single-byte UTF-8 symbols for a Service Name are alphanumeric values (A-Z, a-z, 0-9), the hyphen ('-'), the period ('.') and the underscore ('_'). All valid multi-byte UTF-8 characters are acceptable in a Service Name.

Note: for compatibility with devices running Android 11 or older, avoid using underscore ('_') symbol as a single-byte UTF-8 service name.

Must be called - an empty ServiceName is not valid.

| Parameters ||
|---|---|
| `serviceName` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): The service name for the publish session. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#!` | The builder to facilitate chaining `builder.setXXX(..).setXXX(..)`. |

### setServiceSpecificInfo

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

```
fun setServiceSpecificInfo(serviceSpecificInfo: ByteArray?): PublishConfig.Builder!
```

Specify service specific information for the publish session. This is a free-form byte array available to the application to send additional information as part of the discovery operation - it will not be used to determine whether a publish/subscribe match occurs.

Optional. Empty by default.

| Parameters ||
|---|---|
| `serviceSpecificInfo` | [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)?: A byte-array for the service-specific information field. This value may be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#!` | The builder to facilitate chaining `builder.setXXX(..).setXXX(..)`. |

### setTerminateNotificationEnabled

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

```
fun setTerminateNotificationEnabled(enable: Boolean): PublishConfig.Builder!
```

Configure whether a publish terminate notification `https://developer.android.com/reference/kotlin/android/net/wifi/aware/DiscoverySessionCallback#onSessionTerminated()` is reported back to the callback.

| Parameters ||
|---|---|
| `enable` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html): If true the terminate callback will be called when the publish is terminated. Otherwise it will not be called. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#!` | The builder to facilitate chaining `builder.setXXX(..).setXXX(..)`. |

### setTtlSec

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

```
fun setTtlSec(ttlSec: Int): PublishConfig.Builder!
```

Sets the time interval (in seconds) an unsolicited ( `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#setPublishType(kotlin.Int)`) publish session will be alive - broadcasting a packet. When the TTL is reached an event will be generated for `https://developer.android.com/reference/kotlin/android/net/wifi/aware/DiscoverySessionCallback#onSessionTerminated()` \[unless `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#setTerminateNotificationEnabled(kotlin.Boolean)` disables the callback\].

Optional. 0 by default - indicating the session doesn't terminate on its own. Session will be terminated when `https://developer.android.com/reference/kotlin/android/net/wifi/aware/DiscoverySession#close()` is called.

| Parameters ||
|---|---|
| `ttlSec` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Lifetime of a publish session in seconds. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/net/wifi/aware/PublishConfig.Builder#!` | The builder to facilitate chaining `builder.setXXX(..).setXXX(..)`. |