【问题标题】:Why do I get API: Wearable.API is not available on this device when I try to connect my handheld device app to wearable using android?为什么我会收到 API:当我尝试使用 Android 将我的手持设备应用程序连接到可穿戴设备时,Wearable.API 在此设备上不可用?
【发布时间】: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 和官方文档上搜索了这里,如果有人能指导我如何解决这个问题,我将不胜感激。

【问题讨论】:

    标签: java android wearables


    【解决方案1】:

    我遇到了类似的问题!尝试安装 wearOS app 并重试。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-03
      相关资源
      最近更新 更多