@Override
 public void onResult(DataApi.DataItemResult dataItemResult) {
   if (dataItemResult.getStatus().isSuccess()) {
     if (dataItemResult.getDataItem() != null) {
       DataItem configDataItem = dataItemResult.getDataItem();
       DataMapItem dataMapItem = DataMapItem.fromDataItem(configDataItem);
       DataMap config = dataMapItem.getDataMap();
       mCallback.onConfigDataMapFetched(config);
     } else {
       mCallback.onConfigDataMapFetched(new DataMap());
     }
   }
 }
예제 #2
0
    public void run() {

      if (googleClient != null) {
        PutDataMapRequest putDMR = PutDataMapRequest.create(path);
        putDMR.getDataMap().putAll(dataMap);
        PutDataRequest request = putDMR.asPutDataRequest();
        DataApi.DataItemResult result = Wearable.DataApi.putDataItem(googleClient, request).await();
        if (result.getStatus().isSuccess()) {
          Log.v("myTag", "DataMap: " + dataMap + " sent successfully to data layer ");
        } else {
          // Log an error
          Log.v("myTag", "ERROR: failed to send DataMap to data layer");
        }
      }
    }