gpt4 book ai didi

com.google.android.gms.wearable.Wearable.getNodeClient()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-22 01:37:05 27 4
gpt4 key购买 nike

本文整理了Java中com.google.android.gms.wearable.Wearable.getNodeClient()方法的一些代码示例,展示了Wearable.getNodeClient()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Wearable.getNodeClient()方法的具体详情如下:
包路径:com.google.android.gms.wearable.Wearable
类名称:Wearable
方法名:getNodeClient

Wearable.getNodeClient介绍

暂无

代码示例

代码示例来源:origin: googlesamples/android-DataLayer

@WorkerThread
private Collection<String> getNodes() {
  HashSet<String> results = new HashSet<>();
  Task<List<Node>> nodeListTask =
      Wearable.getNodeClient(getApplicationContext()).getConnectedNodes();
  try {
    // Block on a task and get the result synchronously (because this is on a background
    // thread).
    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;
}

代码示例来源:origin: JimSeker/wearable

public void run() {
    //first get all the nodes, ie connected wearable devices.
    Task<List<Node>> nodeListTask =
      Wearable.getNodeClient(getApplicationContext()).getConnectedNodes();
    try {
      // Block on a task and get the result synchronously (because this is on a background
      // thread).
      List<Node> nodes = Tasks.await(nodeListTask);
      //Now send the message to each device.
      for (Node node : nodes) {
        Task<Integer> sendMessageTask =
          Wearable.getMessageClient(MainActivity.this).sendMessage(node.getId(), path, message.getBytes());
        try {
          // Block on a task and get the result synchronously (because this is on a background
          // thread).
          Integer result = Tasks.await(sendMessageTask);
          Log.v(TAG, "SendThread: message send to " + node.getDisplayName());
        } catch (ExecutionException exception) {
          Log.e(TAG, "Task failed: " + exception);
        } catch (InterruptedException exception) {
          Log.e(TAG, "Interrupt occurred: " + exception);
        }
      }
    } catch (ExecutionException exception) {
      Log.e(TAG, "Task failed: " + exception);
    } catch (InterruptedException exception) {
      Log.e(TAG, "Interrupt occurred: " + exception);
    }
  }
}

代码示例来源:origin: JimSeker/wearable

Wearable.getNodeClient(getApplicationContext()).getConnectedNodes();
try {

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com