Summary: Ctors | Methods | Inherited Methods | [Expand All]
public static class

# Strategy.Builder

extends Object

java.lang.Object
↳ | com.google.android.gms.nearby.messages.Strategy.Builder

## Class Overview

Builder for `Strategy`.

## Summary

Public Constructors
| Strategy.Builder() Creates a new `Strategy.Builder`.

Public Methods
Strategy | build() Builds an instance of `Strategy`.
Strategy.Builder | setDiscoveryMode(int discoveryMode) Sets the desired discovery mode that determines how devices will detect each other.
Strategy.Builder | setDistanceType(int distanceType) If used with a publish, the published message will only be delivered to subscribing devices that are at most the specified distance from this device.
Strategy.Builder | setTtlSeconds(int ttlSeconds) Sets the time to live in seconds for the publish or subscribe.

[Expand] Inherited Methods
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
final void | wait()

## Public Constructors

#### public Strategy.Builder ()

Creates a new `Strategy.Builder`. By default it will have the same settings as a `DEFAULT` strategy.

## Public Methods

#### public Strategy build ()

Builds an instance of `Strategy`.

#### public Strategy.Builder setDiscoveryMode (int discoveryMode)

Sets the desired discovery mode that determines how devices will detect each other.

The discovery mode is orthogonal to if device is publishing or subscribing for messages. It's just the mechanism for detecting nearby devices. By default, the devices will broadcast and scan for pairing codes, so other devices can detect the originator from either a scan or a broadcast as well or both. Doing both allows for inclusion of devices that can only broadcast.

##### Parameters

discoveryMode | One of `Strategy.DISCOVERY_MODE_*` specifying how to detect nearby devices.

#### public Strategy.Builder setDistanceType (int distanceType)

If used with a publish, the published message will only be delivered to subscribing devices that are at most the specified distance from this device.

If used with a subscribe, messages will only be delivered if the publishing device is at most the specified distance from this device.

##### Parameters

distanceType | One of `Strategy.DISTANCE_TYPE_*` specifying how close nearby devices must be.

#### public Strategy.Builder setTtlSeconds (int ttlSeconds)

Sets the time to live in seconds for the publish or subscribe. This must be either `TTL_SECONDS_INFINITE`, or a positive integer between 1 and `TTL_SECONDS_MAX`, inclusive.

If not set, `TTL_SECONDS_DEFAULT` is used instead.