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

# PublishConfig.Builder

*** ** * ** ***


`
public
static
final

class
PublishConfig.Builder
`


`

extends https://developer.android.com/reference/java/lang/Object


`

`


`

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

<br />

*** ** * ** ***

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

## Summary

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

| ### Public methods ||
|---|---|
| ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig` | ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder#build()() ` Build `https://developer.android.com/reference/android/net/wifi/aware/PublishConfig` given the current requests made on the builder. |
| ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder` | ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder#setDataPathSecurityConfig(android.net.wifi.aware.WifiAwareDataPathSecurityConfig)(https://developer.android.com/reference/android/net/wifi/aware/WifiAwareDataPathSecurityConfig securityConfig) ` Configure security config for the Wi-Fi Aware publish session. |
| ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder` | ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder#setFrameworkOffloadedPairingEnabled(boolean)(boolean enabled) ` Configure whether to enable framework offloaded auto-pairing for this publish session. |
| ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder` | ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder#setInstantCommunicationModeEnabled(boolean,%20int)(boolean enabled, int band) ` Configure whether to enable and use instant communication for this publish session. |
| ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder` | ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder#setMatchFilter(java.util.List<byte[]>)(https://developer.android.com/reference/java/util/List<byte[]> matchFilter) ` The match filter for a publish session. |
| ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder` | ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder#setPairingConfig(android.net.wifi.aware.AwarePairingConfig)(https://developer.android.com/reference/android/net/wifi/aware/AwarePairingConfig config) ` Set the `https://developer.android.com/reference/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. |
| ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder` | ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder#setPublishType(int)(int publishType) ` 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). |
| ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder` | ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder#setRangingEnabled(boolean)(boolean enable) ` Configure whether the publish discovery session supports ranging and allows peers to measure distance to it. |
| ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder` | ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder#setServiceName(java.lang.String)(https://developer.android.com/reference/java/lang/String serviceName) ` Specify the service name of the publish session. |
| ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder` | ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder#setServiceSpecificInfo(byte[])(byte[] serviceSpecificInfo) ` Specify service specific information for the publish session. |
| ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder` | ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder#setTerminateNotificationEnabled(boolean)(boolean enable) ` Configure whether a publish terminate notification `https://developer.android.com/reference/android/net/wifi/aware/DiscoverySessionCallback#onSessionTerminated()` is reported back to the callback. |
| ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder` | ` https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder#setTtlSec(int)(int ttlSec) ` Sets the time interval (in seconds) an unsolicited ( `https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder#setPublishType(int)`) publish session will be alive - broadcasting a packet. |

### 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 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public Builder ()
```

Default constructor.

<br />

## Public methods

### build

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

```
public PublishConfig build ()
```

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

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/wifi/aware/PublishConfig` | <br /> |

### setDataPathSecurityConfig

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

```
public PublishConfig.Builder setDataPathSecurityConfig (WifiAwareDataPathSecurityConfig securityConfig)
```

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/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/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/android/net/wifi/aware/ServiceDiscoveryInfo` on the subscriber. Security can still be negotiated
using out-of-band (OOB) mechanisms.

<br />

| Parameters ||
|---|---|
| `securityConfig` | `WifiAwareDataPathSecurityConfig`: The (optional) security config to be used to create security context Identifier. This value cannot be `null`. <br /> |

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

### setFrameworkOffloadedPairingEnabled

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

```
public PublishConfig.Builder setFrameworkOffloadedPairingEnabled (boolean enabled)
```

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/android/net/wifi/aware/AwarePairingConfig` with a framework managed configuration.

<br />

| Parameters ||
|---|---|
| `enabled` | `boolean`: If true, enable framework offloaded auto-pairing. <br /> |

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

### setInstantCommunicationModeEnabled

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

```
public PublishConfig.Builder setInstantCommunicationModeEnabled (boolean enabled, 
                int band)
```

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/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.

<br />

| Parameters ||
|---|---|
| `enabled` | `boolean`: true for enable instant communication mode, default is false. <br /> |
| `band` | `int`: When setting to `https://developer.android.com/reference/android/net/wifi/ScanResult#WIFI_BAND_5_GHZ`, 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/android/net/wifi/ScanResult#WIFI_BAND_24_GHZ` - `https://developer.android.com/reference/android/net/wifi/ScanResult#WIFI_BAND_5_GHZ` |

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

### setMatchFilter

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

```
public PublishConfig.Builder setMatchFilter (List<byte[]> matchFilter)
```

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.

<br />

| Parameters ||
|---|---|
| `matchFilter` | `List`: A list of match filter entries (each of which is an arbitrary byte array). This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder` | The builder to facilitate chaining `builder.setXXX(..).setXXX(..)`. <br /> |

### setPairingConfig

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

```
public PublishConfig.Builder setPairingConfig (AwarePairingConfig config)
```

Set the `https://developer.android.com/reference/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.

<br />

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

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

**See also:**

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

### setPublishType

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

```
public PublishConfig.Builder setPublishType (int publishType)
```

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).

<br />

| Parameters ||
|---|---|
| `publishType` | `int`: Publish session type: `https://developer.android.com/reference/android/net/wifi/aware/PublishConfig#PUBLISH_TYPE_SOLICITED` or `https://developer.android.com/reference/android/net/wifi/aware/PublishConfig#PUBLISH_TYPE_UNSOLICITED` (the default). Value is one of the following: - `https://developer.android.com/reference/android/net/wifi/aware/PublishConfig#PUBLISH_TYPE_UNSOLICITED` - `https://developer.android.com/reference/android/net/wifi/aware/PublishConfig#PUBLISH_TYPE_SOLICITED` |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder` | The builder to facilitate chaining `builder.setXXX(..).setXXX(..)`. <br /> |

### setRangingEnabled

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

```
public PublishConfig.Builder setRangingEnabled (boolean enable)
```

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/android/net/wifi/aware/SubscribeConfig.Builder#setEgressDistanceMm(int)` and
`https://developer.android.com/reference/android/net/wifi/aware/SubscribeConfig.Builder#setIngressDistanceMm(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/android/net/wifi/rtt/package-summary`.

<br />

| Parameters ||
|---|---|
| `enable` | `boolean`: If true, ranging is supported on request of the peer. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder` | The builder to facilitate chaining `builder.setXXX(..).setXXX(..)`. <br /> |

### setServiceName

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

```
public PublishConfig.Builder setServiceName (String serviceName)
```

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.

<br />

| Parameters ||
|---|---|
| `serviceName` | `String`: The service name for the publish session. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder` | The builder to facilitate chaining `builder.setXXX(..).setXXX(..)`. <br /> |

### setServiceSpecificInfo

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

```
public PublishConfig.Builder setServiceSpecificInfo (byte[] serviceSpecificInfo)
```

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.

<br />

| Parameters ||
|---|---|
| `serviceSpecificInfo` | `byte`: A byte-array for the service-specific information field. This value may be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder` | The builder to facilitate chaining `builder.setXXX(..).setXXX(..)`. <br /> |

### setTerminateNotificationEnabled

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

```
public PublishConfig.Builder setTerminateNotificationEnabled (boolean enable)
```

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

<br />

| Parameters ||
|---|---|
| `enable` | `boolean`: If true the terminate callback will be called when the publish is terminated. Otherwise it will not be called. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder` | The builder to facilitate chaining `builder.setXXX(..).setXXX(..)`. <br /> |

### setTtlSec

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

```
public PublishConfig.Builder setTtlSec (int ttlSec)
```

Sets the time interval (in seconds) an unsolicited (
`https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder#setPublishType(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/android/net/wifi/aware/DiscoverySessionCallback#onSessionTerminated()` \[unless
`https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder#setTerminateNotificationEnabled(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/android/net/wifi/aware/DiscoverySession#close()` is
called.

<br />

| Parameters ||
|---|---|
| `ttlSec` | `int`: Lifetime of a publish session in seconds. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/net/wifi/aware/PublishConfig.Builder` | The builder to facilitate chaining `builder.setXXX(..).setXXX(..)`. <br /> |