Example #1
0
 /**
  * Sends the asset that was created form 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();
   Wearable.DataApi.putDataItem(mMobvoiApiClient, request)
       .setResultCallback(
           new ResultCallback<DataItemResult>() {
             @Override
             public void onResult(DataItemResult dataItemResult) {
               LOGD(
                   TAG, "Sending image was successful: " + dataItemResult.getStatus().isSuccess());
             }
           });
 }
Example #2
0
    @Override
    public void run() {
      PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(COUNT_PATH);
      putDataMapRequest.getDataMap().putInt(COUNT_KEY, count++);
      PutDataRequest request = putDataMapRequest.asPutDataRequest();

      LOGD(TAG, "Generating DataItem: " + request);
      if (!mMobvoiApiClient.isConnected()) {
        return;
      }
      Wearable.DataApi.putDataItem(mMobvoiApiClient, request)
          .setResultCallback(
              new ResultCallback<DataItemResult>() {
                @Override
                public void onResult(DataItemResult dataItemResult) {
                  if (!dataItemResult.getStatus().isSuccess()) {
                    Log.e(
                        TAG,
                        "ERROR: failed to putDataItem, status code: "
                            + dataItemResult.getStatus().getStatusCode());
                  }
                }
              });
    }