Strategy

public class Strategy extends Object
implements Parcelable

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.

Nested Class Summary

class Strategy.Builder Builder for Strategy

Constant Summary

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.

Inherited Constant Summary

Field Summary

public static final Strategy BLE_ONLY This field is deprecated. Use DEFAULT instead, which is also limited to only BLE.
public static final Creator<Strategy> CREATOR
public static final Strategy DEFAULT The default strategy, which is suitable for most applications.

Public Method Summary

boolean
equals(Object other)
int
String
void
writeToParcel(Parcel out, int flags)

Inherited Method Summary

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

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

public static final int DISCOVERY_MODE_SCAN

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

Constant Value: 2

public static final int DISTANCE_TYPE_DEFAULT

Allows the message be exchanged over any distance.

Constant Value: 0

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

public static final int TTL_SECONDS_DEFAULT

The default time to live in seconds.

Constant Value: 300

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

public static final int TTL_SECONDS_MAX

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

Constant Value: 86400

Fields

public static final Strategy BLE_ONLY

This field is deprecated.
Use DEFAULT instead, which is also limited to only BLE.

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.

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)