NodeClient

  • NodeClient exposes an API for learning about local or connected Nodes, with node events delivered to all applications on a device.

  • New code should use CapabilityClient for creating and listening to application-specific network events instead of NodeClient.

  • NodeClient provides methods to get information about connected nodes, the local node, and the companion package or node ID for a given node.

  • NodeClient includes a constant for the node migration action and a listener interface for node migration events.

public abstract class NodeClient extends GoogleApi<Wearable.WearableOptions>

Exposes an API for learning about local or connected Nodes.

Node events are delivered to all applications on a device.

New code should use CapabilityClient which allows you to create and listen to application-specific network events.

Nested Class Summary

interface NodeClient.OnNodeMigratedListener Receives events after a node migration has successfully finished.

Constant Summary

String ACTION_NODE_MIGRATED Node migration action for use in manifest-based listener filters.

Public Method Summary

abstract Task<String>
getCompanionPackageForNode (String watchNodeId)
Gets the package name for the Companion application associated with this node.
abstract Task<List<Node>>
getConnectedNodes ()
Gets a list of nodes to which this device is currently connected, either directly or indirectly via a directly connected node.
abstract Task<Node>
getLocalNode ()
Gets the Node that refers to this device.
abstract Task<String>
getNodeId (String bluetoothAddress)
Gets the node ID associated with a bluetooth address.

Inherited Method Summary

From class com.google.android.gms.common.api.GoogleApi
String
getApiFallbackAttributionTag(Context arg0)
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()

Constants

public static final String ACTION_NODE_MIGRATED

Node migration action for use in manifest-based listener filters.

Constant Value: "com.google.android.gms.wearable.NODE_MIGRATED"

Public Methods

public abstract Task<String> getCompanionPackageForNode (String watchNodeId)

Gets the package name for the Companion application associated with this node.

Parameters
watchNodeId must be a valid nodeId corresponding to a connected watch
Returns
  • a Companion application package name; returns an empty string instead if none are associated, or if the specified watch is not currently connected

public abstract Task<List<Node>> getConnectedNodes ()

Gets a list of nodes to which this device is currently connected, either directly or indirectly via a directly connected node.

The returned list will not include the local node .

public abstract Task<Node> getLocalNode ()

Gets the Node that refers to this device. The information in the returned Node can be passed to other devices using MessageClient , for example.

public abstract Task<String> getNodeId (String bluetoothAddress)

Gets the node ID associated with a bluetooth address.

Parameters
bluetoothAddress must be a valid bluetooth address corresponding to a paired watch
Returns
  • the nodeId associated with the device

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024年11月21日 UTC.