Summary: Nested Classes | Constants | Inherited Constants | Fields | Methods | Inherited Methods | [Expand All]
public class

# Strategy

extends Object
implements SafeParcelable

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

## Class Overview

Describes a set of strategies for publishing or subscribing for nearby messages. If one of the provided strategies doesn't work, consider using a `Strategy.Builder`.

## Summary

Nested Classes
class | Strategy.Builder | Builder for `Strategy`.

Constants
int | DISCOVERY_MODE_BROADCAST | To discover which devices are nearby, broadcast a pairing code for others to scan.
int | DISCOVERY_MODE_DEFAULT | To discover which devices are nearby, broadcast a pairing code and scan for other devices' pairing codes.
int | DISCOVERY_MODE_SCAN | To discover which devices are nearby, scan for other devices' pairing codes.
int | DISTANCE_TYPE_DEFAULT | Allows the message be exchanged over any distance.
int | DISTANCE_TYPE_EARSHOT | Allows the message be exchanged within earshot only.
int | TTL_SECONDS_DEFAULT | The default time to live in seconds.
int | TTL_SECONDS_INFINITE | An infinite time to live in seconds.
int | TTL_SECONDS_MAX | The maximum time to live in seconds, if not `TTL_SECONDS_INFINITE`.

[Expand] Inherited Constants
From interface com.google.android.gms.common.internal.safeparcel.SafeParcelable
String | NULL |
From interface android.os.Parcelable
int | CONTENTS_FILE_DESCRIPTOR |
int | PARCELABLE_WRITE_RETURN_VALUE |

Fields
public static final Strategy | BLE_ONLY | Use only Bluetooth Low Energy to discover nearby devices.
public static final Creator<Strategy> | CREATOR |
public static final Strategy | DEFAULT | The default strategy, which is suitable for most applications.

Public Methods
boolean | equals(Object other)
int | hashCode()
String | toString()
void | writeToParcel(Parcel out, int flags)

[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()
From interface android.os.Parcelable
abstract int | describeContents()
abstract void | writeToParcel(Parcel arg0, int arg1)

## Constants

#### public static final int DISCOVERY_MODE_BROADCAST

To discover which devices are nearby, broadcast a pairing code for others to scan.

Constant Value: 1 (0x00000001)

#### public static final int DISCOVERY_MODE_DEFAULT

To discover which devices are nearby, broadcast a pairing code and scan for other devices' pairing codes. This is equivalent to `DISCOVERY_MODE_BROADCAST` | `DISCOVERY_MODE_SCAN`.

Constant Value: 3 (0x00000003)

#### public static final int DISCOVERY_MODE_SCAN

To discover which devices are nearby, scan for other devices' pairing codes.

Constant Value: 2 (0x00000002)

#### public static final int DISTANCE_TYPE_DEFAULT

Allows the message be exchanged over any distance.

Constant Value: 0 (0x00000000)

#### public static final int DISTANCE_TYPE_EARSHOT

Allows the message be exchanged within earshot only.

It is recommended that this configuration is used in conjunction with `DISCOVERY_MODE_BROADCAST`. This will improve the detection latency.

Constant Value: 1 (0x00000001)

#### public static final int TTL_SECONDS_DEFAULT

The default time to live in seconds.

Constant Value: 300 (0x0000012c)

#### public static final int TTL_SECONDS_INFINITE

An infinite time to live in seconds.

Note: This is currently only supported for subscriptions.

Constant Value: 2147483647 (0x7fffffff)

#### public static final int TTL_SECONDS_MAX

The maximum time to live in seconds, if not `TTL_SECONDS_INFINITE`.

Constant Value: 86400 (0x00015180)

## Fields

#### public static final Strategy BLE_ONLY

Use only Bluetooth Low Energy to discover nearby devices. Recommended if you are only interested in messages attached to BLE beacons.

The time to live of this strategy is `TTL_SECONDS_INFINITE` and as such it's only supported for subscriptions.

Bluetooth Low Energy is not supported on all Android devices.

##### See Also

- Bluetooth Low Energy | Android Developers

#### public static final Creator<Strategy> CREATOR

#### public static final Strategy DEFAULT

The default strategy, which is suitable for most applications.

The default behavior is currently doing broadcasts and scans, using all available sensors, to discover nearby devices, regardless of distance.

## Public Methods

#### public boolean equals (Object other)

#### public int hashCode ()

#### public String toString ()

#### public void writeToParcel (Parcel out, int flags)