Strategy

public final class Strategy extends AbstractSafeParcelable

The Strategy to be used when discovering or advertising to Nearby devices. The Strategy defines

  1. the connectivity requirements for the device, and
  2. the topology constraints of the connection.

Inherited Constant Summary

Field Summary

public static final Strategy P2P_CLUSTER Peer-to-peer strategy that supports an M-to-N, or cluster-shaped, connection topology.
public static final Strategy P2P_POINT_TO_POINT Peer-to-peer strategy that supports a 1-to-1 connection topology.
public static final Strategy P2P_STAR Peer-to-peer strategy that supports a 1-to-N, or star-shaped, connection topology.

Public Method Summary

boolean
equals(Object object)
int
String

Inherited Method Summary

Fields

public static final Strategy P2P_CLUSTER

Peer-to-peer strategy that supports an M-to-N, or cluster-shaped, connection topology. In other words, this enables connecting amorphous clusters of devices within radio range (~100m), where each device can both initiate outgoing connections to M other devices and accept incoming connections from N other devices.

This is the default strategy, equivalent to calling the deprecated Connections API methods with no Strategy parameter.

In order to advertise with this Strategy, your app must declare the following permissions:

  • BLUETOOTH
  • BLUETOOTH_ADMIN
  • ACCESS_WIFI_STATE
  • CHANGE_WIFI_STATE

In order to discover with this Strategy, your app must declare all of the above permissions, plus ACCESS_COARSE_LOCATION (Required for devices running M+).

public static final Strategy P2P_POINT_TO_POINT

Peer-to-peer strategy that supports a 1-to-1 connection topology. In other words, this enables connecting to a single device within radio range (~100m). This strategy will give the absolute highest bandwidth, but will not allow multiple connections at a time.

In order to advertise with this Strategy, your app must declare the following permissions:

  • BLUETOOTH
  • BLUETOOTH_ADMIN
  • ACCESS_WIFI_STATE
  • CHANGE_WIFI_STATE

In order to discover with this Strategy, your app must declare all of the above permissions, plus ACCESS_COARSE_LOCATION (Required for devices running M+).

public static final Strategy P2P_STAR

Peer-to-peer strategy that supports a 1-to-N, or star-shaped, connection topology. In other words, this enables connecting devices within radio range (~100m) in a star shape, where each device can, at any given time, play the role of either a hub (where it can accept incoming connections from N other devices), or a spoke (where it can initiate an outgoing connection to a single hub), but not both.

This strategy lends itself best to one device who advertises itself, and N devices who discover that advertisement, though you may still advertise and discover simultaneously if required.

In order to advertise with this Strategy, your app must declare the following permissions:

  • BLUETOOTH
  • BLUETOOTH_ADMIN
  • ACCESS_WIFI_STATE
  • CHANGE_WIFI_STATE

In order to discover with this Strategy, your app must declare all of the above permissions, plus ACCESS_COARSE_LOCATION (Required for devices running M+).

Public Methods

public boolean equals (Object object)

public int hashCode ()

public String toString ()