gpt4 book ai didi

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

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

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

Wearable.getDataClient介绍

暂无

代码示例

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

@Override
public void onResume() {
  super.onResume();
  Wearable.getDataClient(this).addListener(this);
}

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

@Override
public void onPause() {
  super.onPause();
  Wearable.getDataClient(this).removeListener(this);
}

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

@Override
public void onResume() {
  super.onResume();
  Wearable.getDataClient(this).addListener(this);
}

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

@Override
public void onPause() {
  super.onPause();
  Wearable.getDataClient(this).removeListener(this);
}

代码示例来源: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: Calsign/APDE

protected boolean makeFileFromAsset(Asset asset, File destFile) {
  try {
    InputStream inputStream = Tasks.await(Wearable.getDataClient(this).getFdForAsset(asset)).getInputStream();
    if (inputStream != null) {
      createFileFromInputStream(inputStream, destFile, true);
      return true;
    }
  } catch (ExecutionException | InterruptedException | IOException e) {
    e.printStackTrace();
  }
  
  return false;
}

代码示例来源: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: googlesamples/android-DataLayer

@Override
  public void run() {
    PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(COUNT_PATH);
    putDataMapRequest.getDataMap().putInt(COUNT_KEY, count++);
    PutDataRequest request = putDataMapRequest.asPutDataRequest();
    request.setUrgent();
    LOGD(TAG, "Generating DataItem: " + request);
    Task<DataItem> dataItemTask =
        Wearable.getDataClient(getApplicationContext()).putDataItem(request);
    try {
      // Block on a task and get the result synchronously (because this is on a background
      // thread).
      DataItem dataItem = Tasks.await(dataItemTask);
      LOGD(TAG, "DataItem saved: " + dataItem);
    } catch (ExecutionException exception) {
      Log.e(TAG, "Task failed: " + exception);
    } catch (InterruptedException exception) {
      Log.e(TAG, "Interrupt occurred: " + exception);
    }
  }
}

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

/**
 * Sends the asset that was created from the photo we took by adding it to the Data Item store.
 */
private void sendPhoto(Asset asset) {
  PutDataMapRequest dataMap = PutDataMapRequest.create(IMAGE_PATH);
  dataMap.getDataMap().putAsset(IMAGE_KEY, asset);
  dataMap.getDataMap().putLong("time", new Date().getTime());
  PutDataRequest request = dataMap.asPutDataRequest();
  request.setUrgent();
  Task<DataItem> dataItemTask = Wearable.getDataClient(this).putDataItem(request);
  dataItemTask.addOnSuccessListener(
      new OnSuccessListener<DataItem>() {
        @Override
        public void onSuccess(DataItem dataItem) {
          LOGD(TAG, "Sending image was successful: " + dataItem);
        }
      });
}

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

public static void sendApkToWatch(Context context, File apkFile, final ResultCallback callback) {
  Uri apkUri = FileProvider.getUriForFile(context, "com.calsignlabs.apde.fileprovider", apkFile);
  Asset asset = Asset.createFromUri(apkUri);
  PutDataMapRequest dataMap = PutDataMapRequest.create("/apk");
  dataMap.getDataMap().putAsset("apk", asset);
  dataMap.getDataMap().putLong("timestamp", System.currentTimeMillis());
  PutDataRequest request = dataMap.asPutDataRequest();
  request.setUrgent();
  
  Task<DataItem> putTask = Wearable.getDataClient(context).putDataItem(request);
  putTask.addOnCompleteListener(new OnCompleteListener<DataItem>() {
    @Override
    public void onComplete(@NonNull Task<DataItem> task) {
      if (task.isSuccessful()) {
        callback.success();
      } else {
        callback.failure();
      }
    }
  });
}

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

/**
   * Sends the data, note this is a broadcast, so we will get the message as well.
   */
  private void sendData(String message) {
    PutDataMapRequest dataMap = PutDataMapRequest.create(datapath);
    dataMap.getDataMap().putString("message", message);
    PutDataRequest request = dataMap.asPutDataRequest();
    request.setUrgent();

    Task<DataItem> dataItemTask = Wearable.getDataClient(this).putDataItem(request);
    dataItemTask
      .addOnSuccessListener(new OnSuccessListener<DataItem>() {
        @Override
        public void onSuccess(DataItem dataItem) {
          Log.d(TAG, "Sending message was successful: " + dataItem);
        }
      })
      .addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
          Log.e(TAG, "Sending message failed: " + e);
        }
      })
    ;
  }
}

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

/**
   * Sends the data.  Since it specify a client, everyone who is listening to the path, will
   * get the data.
   */
  private void sendData(String message) {
    PutDataMapRequest dataMap = PutDataMapRequest.create(datapath);
    dataMap.getDataMap().putString("message", message);
    PutDataRequest request = dataMap.asPutDataRequest();
    request.setUrgent();

    Task<DataItem> dataItemTask = Wearable.getDataClient(this).putDataItem(request);
    dataItemTask
      .addOnSuccessListener(new OnSuccessListener<DataItem>() {
        @Override
        public void onSuccess(DataItem dataItem) {
          Log.d(TAG, "Sending message was successful: " + dataItem);
        }
      })
      .addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
          Log.e(TAG, "Sending message failed: " + e);
        }
      })
    ;
  }
}

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