lightbulb_outline Help shape the future of the Google Play Console, Android Studio, and Firebase. Start survey

PublishConfig.Builder

public static final class PublishConfig.Builder
extends Object

java.lang.Object
   ↳ android.net.wifi.aware.PublishConfig.Builder


Builder used to build PublishConfig objects.

Summary

Public constructors

PublishConfig.Builder()

Public methods

PublishConfig build()

Build PublishConfig given the current requests made on the builder.

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

The match filter for a publish session.

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

PublishConfig.Builder setRangingEnabled(boolean enable)

Configure whether the publish discovery session supports ranging and allows peers to measure distance to it.

PublishConfig.Builder setServiceName(String serviceName)

Specify the service name of the publish session.

PublishConfig.Builder setServiceSpecificInfo(byte[] serviceSpecificInfo)

Specify service specific information for the publish session.

PublishConfig.Builder setTerminateNotificationEnabled(boolean enable)

Configure whether a publish terminate notification DiscoverySessionCallback.onSessionTerminated() is reported back to the callback.

PublishConfig.Builder setTtlSec(int ttlSec)

Sets the time interval (in seconds) an unsolicited ( setPublishType(int)) publish session will be alive - broadcasting a packet.

Inherited methods

Public constructors

PublishConfig.Builder

added in API level 26
public PublishConfig.Builder ()

Public methods

build

added in API level 26
public PublishConfig build ()

Build PublishConfig given the current requests made on the builder.

Returns
PublishConfig

setMatchFilter

added in API level 26
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.

Parameters
matchFilter List: A list of match filter entries (each of which is an arbitrary byte array).

This value may be null.

Returns
PublishConfig.Builder The builder to facilitate chaining builder.setXXX(..).setXXX(..).

setPublishType

added in API level 26
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).

Parameters
publishType int: Publish session type: PublishConfig.PUBLISH_TYPE_SOLICITED or PublishConfig.PUBLISH_TYPE_UNSOLICITED (the default).

Returns
PublishConfig.Builder The builder to facilitate chaining builder.setXXX(..).setXXX(..).

setRangingEnabled

added in API level 28
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 SubscribeConfig.Builder.setMinDistanceMm(int) and SubscribeConfig.Builder.setMaxDistanceMm(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 android.net.wifi.rtt.

Parameters
enable boolean: If true, ranging is supported on request of the peer.

Returns
PublishConfig.Builder The builder to facilitate chaining builder.setXXX(..).setXXX(..).

setServiceName

added in API level 26
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 ('-'), and the period ('.'). All valid multi-byte UTF-8 characters are acceptable in a Service Name.

Must be called - an empty ServiceName is not valid.

Parameters
serviceName String: The service name for the publish session.

This value must never be null.

Returns
PublishConfig.Builder The builder to facilitate chaining builder.setXXX(..).setXXX(..).

setServiceSpecificInfo

added in API level 26
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.

Parameters
serviceSpecificInfo byte: A byte-array for the service-specific information field.

This value may be null.

Returns
PublishConfig.Builder The builder to facilitate chaining builder.setXXX(..).setXXX(..).

setTerminateNotificationEnabled

added in API level 26
public PublishConfig.Builder setTerminateNotificationEnabled (boolean enable)

Configure whether a publish terminate notification DiscoverySessionCallback.onSessionTerminated() is reported back to the callback.

Parameters
enable boolean: If true the terminate callback will be called when the publish is terminated. Otherwise it will not be called.

Returns
PublishConfig.Builder The builder to facilitate chaining builder.setXXX(..).setXXX(..).

setTtlSec

added in API level 26
public PublishConfig.Builder setTtlSec (int ttlSec)

Sets the time interval (in seconds) an unsolicited ( setPublishType(int)) publish session will be alive - broadcasting a packet. When the TTL is reached an event will be generated for DiscoverySessionCallback.onSessionTerminated() [unless setTerminateNotificationEnabled(boolean) disables the callback].

Optional. 0 by default - indicating the session doesn't terminate on its own. Session will be terminated when DiscoverySession.close() is called.

Parameters
ttlSec int: Lifetime of a publish session in seconds.

Returns
PublishConfig.Builder The builder to facilitate chaining builder.setXXX(..).setXXX(..).