public class WearableNode

  1. Object
  2. WearableNode

A device on the other end of the link: the watch as seen from the phone, or the phone as seen from the watch.

Apple pairs a phone with exactly one watch at a time, so there is at most one node there. Wear OS allows several watches paired to one phone, so a phone app can see more than one – send to all of them unless you have a reason to pick.

Constructors

public WearableNode(String id, String displayName, boolean nearby)Creates a node description.

Methods

public String getId()Returns the platform’s opaque identifier for this device, stable for as long as the pairing lasts.
public String getDisplayName()Returns the device name a person would recognize, suitable for showing in a UI.
public boolean isNearby()Returns true when the device is directly connected (Bluetooth or the same network) rather than merely reachable through the cloud.
public String toString()Returns a string representation of the object.

Inherited methods

Constructor details

WearableNode

public WearableNode(String id, String displayName, boolean nearby)
Creates a node description. Called by the platform ports; application code obtains nodes from WearableConnection.getConnectedNodes().

Parameters

id String
the platform’s opaque identifier for the device
displayName String
the device name a person would recognize
nearby boolean
true when the device is directly connected rather than reachable over the cloud

Method details

getId

public String getId()
Returns the platform’s opaque identifier for this device, stable for as long as the pairing lasts.

Returns

the node id

getDisplayName

public String getDisplayName()
Returns the device name a person would recognize, suitable for showing in a UI.

Returns

the display name

isNearby

public boolean isNearby()

Returns true when the device is directly connected (Bluetooth or the same network) rather than merely reachable through the cloud.

Informational, not a delivery rule. A cloud-routed peer still receives messages, requests and replicated data – it appears in the connected set, which is what “connected” means – so WearableConnection.isReachable and message delivery do not consult this. Expect higher latency, and an actual failure is reported through the send’s own error path rather than predicted from the transport.

Returns

true if the node is directly connected

toString

public String toString()
Returns a string representation of the object. In general, the toString method returns a string that “textually represents” this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@’, and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + ‘@’ + Integer.toHexString(hashCode())