NodeClient
Stay organized with collections
Save and categorize content based on your preferences.
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.
Public Method Summary
abstract Task<String>
|
|
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>
|
|
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
From class java.lang.Object
Object
|
clone()
|
boolean |
|
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.
[null,null,["Last updated 2024-11-21 UTC."],[[["\u003cp\u003e\u003ccode\u003eNodeClient\u003c/code\u003e provides an API for accessing information about local and connected nodes in a wearable network.\u003c/p\u003e\n"],["\u003cp\u003eNode events are delivered to all applications on a device.\u003c/p\u003e\n"],["\u003cp\u003eFor application-specific network events, use \u003ccode\u003eCapabilityClient\u003c/code\u003e instead.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eNodeClient\u003c/code\u003e offers methods to get connected nodes, local node details, and the companion app package for a node.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eACTION_NODE_MIGRATED\u003c/code\u003e constant is used for manifest-based listener filters related to node migration.\u003c/p\u003e\n"]]],[],null,["# NodeClient\n\npublic abstract class **NodeClient** extends [GoogleApi](/android/reference/com/google/android/gms/common/api/GoogleApi)\\\u003c[Wearable.WearableOptions](/android/reference/com/google/android/gms/wearable/Wearable.WearableOptions)\\\u003e \nExposes an API for learning about local or connected Nodes.\n\nNode events are delivered to all applications on a device.\n\nNew code should use [CapabilityClient](/android/reference/com/google/android/gms/wearable/CapabilityClient)\nwhich allows you to create and listen to application-specific network events. \n\n### Nested Class Summary\n\n|-----------|---|---|-------------------------------------------------------------------|\n| interface | [NodeClient.OnNodeMigratedListener](/android/reference/com/google/android/gms/wearable/NodeClient.OnNodeMigratedListener) || Receives events after a node migration has successfully finished. |\n\n### Constant Summary\n\n|-------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|\n| [String](//developer.android.com/reference/java/lang/String.html) | [ACTION_NODE_MIGRATED](/android/reference/com/google/android/gms/wearable/NodeClient#ACTION_NODE_MIGRATED) | Node migration action for use in manifest-based listener filters. |\n\n### Public Method Summary\n\n|---------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract Task\\\u003c[String](//developer.android.com/reference/java/lang/String.html)\\\u003e | [getCompanionPackageForNode](/android/reference/com/google/android/gms/wearable/NodeClient#getCompanionPackageForNode(java.lang.String))([String](//developer.android.com/reference/java/lang/String.html) watchNodeId) Gets the package name for the Companion application associated with this node. |\n| abstract Task\\\u003c[List](//developer.android.com/reference/java/util/List.html)\\\u003c[Node](/android/reference/com/google/android/gms/wearable/Node)\\\u003e\\\u003e | [getConnectedNodes](/android/reference/com/google/android/gms/wearable/NodeClient#getConnectedNodes())() Gets a list of nodes to which this device is currently connected, either directly or indirectly via a directly connected node. |\n| abstract Task\\\u003c[Node](/android/reference/com/google/android/gms/wearable/Node)\\\u003e | [getLocalNode](/android/reference/com/google/android/gms/wearable/NodeClient#getLocalNode())() Gets the [Node](/android/reference/com/google/android/gms/wearable/Node) that refers to this device. |\n| abstract Task\\\u003c[String](//developer.android.com/reference/java/lang/String.html)\\\u003e | [getNodeId](/android/reference/com/google/android/gms/wearable/NodeClient#getNodeId(java.lang.String))([String](//developer.android.com/reference/java/lang/String.html) bluetoothAddress) Gets the node ID associated with a bluetooth address. |\n\n### Inherited Method Summary\n\nFrom class com.google.android.gms.common.api.GoogleApi \n\n|-------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|\n| [String](//developer.android.com/reference/java/lang/String.html) | getApiFallbackAttributionTag([Context](//developer.android.com/reference/android/content/Context.html) arg0) |\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nConstants\n---------\n\n#### public static final [String](//developer.android.com/reference/java/lang/String.html)\n**ACTION_NODE_MIGRATED**\n\nNode migration action for use in manifest-based listener filters. \n\n##### See Also\n\n- [WearableListenerService](/android/reference/com/google/android/gms/wearable/WearableListenerService)\n- [NodeClient.OnNodeMigratedListener](/android/reference/com/google/android/gms/wearable/NodeClient.OnNodeMigratedListener) \nConstant Value: \"com.google.android.gms.wearable.NODE_MIGRATED\"\n\nPublic Methods\n--------------\n\n#### public abstract Task\\\u003c[String](//developer.android.com/reference/java/lang/String.html)\\\u003e\n**getCompanionPackageForNode** ([String](//developer.android.com/reference/java/lang/String.html) watchNodeId)\n\nGets the package name for the Companion application associated with this node. \n\n##### Parameters\n\n| watchNodeId | must be a valid nodeId corresponding to a connected watch |\n|-------------|-----------------------------------------------------------|\n\n##### Returns\n\n- a Companion application package name; returns an empty string instead if none are associated, or if the specified watch is not currently connected \n\n#### public abstract Task\\\u003c[List](//developer.android.com/reference/java/util/List.html)\\\u003c[Node](/android/reference/com/google/android/gms/wearable/Node)\\\u003e\\\u003e\n**getConnectedNodes** ()\n\nGets a list of nodes to which this device is currently connected, either directly or\nindirectly via a directly connected node.\n\nThe returned list will not include the [local\nnode](/android/reference/com/google/android/gms/wearable/NodeClient#getLocalNode()). \n\n#### public abstract Task\\\u003c[Node](/android/reference/com/google/android/gms/wearable/Node)\\\u003e\n**getLocalNode** ()\n\nGets the [Node](/android/reference/com/google/android/gms/wearable/Node) that\nrefers to this device. The information in the returned [Node](/android/reference/com/google/android/gms/wearable/Node) can be\npassed to other devices using [MessageClient](/android/reference/com/google/android/gms/wearable/MessageClient),\nfor example. \n\n#### public abstract Task\\\u003c[String](//developer.android.com/reference/java/lang/String.html)\\\u003e\n**getNodeId** ([String](//developer.android.com/reference/java/lang/String.html) bluetoothAddress)\n\nGets the node ID associated with a bluetooth address. \n\n##### Parameters\n\n| bluetoothAddress | must be a valid bluetooth address corresponding to a paired watch |\n|------------------|-------------------------------------------------------------------|\n\n##### Returns\n\n- the nodeId associated with the device"]]