I am trying to build an android app that can connect to a smartwatch, I've followed the official docs on this page to use the DataLayer to connect both devices, right now I am struggling with finding the connected nodes so I can get the nodeId of the wearable and use it to connect to the watch.
This is what I did so far:
private Collection<String> getNodes() {
HashSet<String> results = new HashSet<>();
Task<List<Node>> nodeListTask =
Wearable.getNodeClient(this).getConnectedNodes();
try {
List<Node> nodes = Tasks.await(nodeListTask);
for (Node node : nodes) {
results.add(node.getId());
}
} catch (ExecutionException exception) {
Log.e(TAG, "Task failed: " + exception);
} catch (InterruptedException exception) {
Log.e(TAG, "Interrupt occurred: " + exception);
}
return results;
}
but I get this error when I launch the app:
com.google.android.gms.common.api.ApiException: 17: API: Wearable.API is not available on this device.
I also followed the sample provided by google and I still couldn't fix this issue, I searched here on StackOverflow and on the official docs and I would appreciate it if someone can guide me on how to fix this.