コード例 #1
0
  private boolean getConnectedBandClient() throws InterruptedException, BandException {
    if (client == null) {
      BandInfo[] devices = BandClientManager.getInstance().getPairedBands();
      if (devices.length == 0) {
        appendToUI("Band isn't paired with your phone.\n", 1);
        return false;
      }
      client = BandClientManager.getInstance().create(getBaseContext(), devices[0]);
    } else if (ConnectionState.CONNECTED == client.getConnectionState()) {
      return true;
    }

    appendToUI("Band is connecting...\n", 1);
    return ConnectionState.CONNECTED == client.connect().await();
  }
コード例 #2
0
  private boolean getConnectedBandClient() throws BandException {
    if (client == null) {
      BandInfo[] devices = BandClientManager.getInstance().getPairedBands();
      if (devices.length == 0) {
        Log.e(TAG, "Band isn't paired with your phone.");
        return false;
      }
      client = BandClientManager.getInstance().create(context, devices[0]);
    } else if (ConnectionState.CONNECTED == client.getConnectionState()) {
      return true;
    }

    Log.i(TAG, "Band is connecting...");
    try {
      return ConnectionState.CONNECTED == client.connect().await();
    } catch (InterruptedException e) {
      return false;
    }
  }