gpt4 book ai didi

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

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

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

Wearable.getCapabilityClient介绍

暂无

代码示例

代码示例来源:origin: Calsign/APDE

public static void initMessageBroadcaster(final Context context) {
  Wearable.getCapabilityClient(context).addListener(new CapabilityClient.OnCapabilityChangedListener() {
    @Override
    public void onCapabilityChanged(@NonNull CapabilityInfo capabilityInfo) {
      updateBestNode(context);
    }
  }, "apde_receive_logs");
  
  // Can't do this on the main thread
  (new Thread(new Runnable() {
    @Override
    public void run() {
      updateBestNode(context);
    }
  })).start();
}

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

@Override
public void onResume() {
  super.onResume();
  mDataItemGeneratorFuture =
      mGeneratorExecutor.scheduleWithFixedDelay(
          new DataItemGenerator(), 1, 5, TimeUnit.SECONDS);
  mStartActivityBtn.setEnabled(true);
  mSendPhotoBtn.setEnabled(mCameraSupported);
  // Instantiates clients without member variables, as clients are inexpensive to create and
  // won't lose their listeners. (They are cached and shared between GoogleApi instances.)
  Wearable.getDataClient(this).addListener(this);
  Wearable.getMessageClient(this).addListener(this);
  Wearable.getCapabilityClient(this)
      .addListener(this, Uri.parse("wear://"), CapabilityClient.FILTER_REACHABLE);
}

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

@Override
public void onPause() {
  super.onPause();
  mDataItemGeneratorFuture.cancel(true /* mayInterruptIfRunning */);
  Wearable.getDataClient(this).removeListener(this);
  Wearable.getMessageClient(this).removeListener(this);
  Wearable.getCapabilityClient(this).removeListener(this);
}

代码示例来源:origin: Calsign/APDE

private static void updateBestNode(Context context) {
  bestNodeId = null;
  
  try {
    CapabilityInfo info = Tasks.await(Wearable.getCapabilityClient(context).getCapability("apde_receive_logs", CapabilityClient.FILTER_REACHABLE));
    for (Node node : info.getNodes()) {
      if (node.isNearby()) {
        bestNodeId = node.getId();
      }
    }
  } catch (Exception e) {
    // Don't call printStackTrace() because that would make an infinite loop
    Log.e("apde", e.toString());
  }
}

代码示例来源:origin: Calsign/APDE

@Override
  public void run() {
    boolean successful = false;
    
    try {
      CapabilityInfo info = Tasks.await(Wearable.getCapabilityClient(context).getCapability("apde_run_watch_sketches", CapabilityClient.FILTER_REACHABLE));
      
      for (Node node : info.getNodes()) {
        if (node.isNearby()) {
          successful = true;
          break;
        }
      }
    } catch (ExecutionException | InterruptedException e) {
      e.printStackTrace();
    }
    
    if (successful) {
      callback.success();
    } else {
      callback.failure();
    }
  }
})).start();

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