【发布时间】:2022-12-30 02:46:49
【问题描述】:
我正在尝试构建一个可以连接到智能手表的 android 应用程序,我已经按照this page 上的官方文档使用 DataLayer 连接两个设备,现在我正在努力寻找连接的节点以便我可以获得可穿戴设备的 nodeId 并使用它连接到手表。
这是我到目前为止所做的:
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;
}
但是当我启动应用程序时出现此错误:
com.google.android.gms.common.api.ApiException: 17: API: Wearable.API is not available on this device.
我也关注了 google 提供的the sample,但我仍然无法解决这个问题,我在 StackOverflow 和官方文档上搜索了这里,如果有人能指导我如何解决这个问题,我将不胜感激。
【问题讨论】: