@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 (!mGoogleApiClient.isConnected()) { return; } Wearable.DataApi.putDataItem(mGoogleApiClient, 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()); } } }); }
/** * 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(mGoogleApiClient, request) .setResultCallback(new ResultCallback<DataItemResult>() { @Override public void onResult(DataItemResult dataItemResult) { LOGD(TAG, "Sending image was successful: " + dataItemResult.getStatus() .isSuccess()); } }); }
@Override public void run() { //不断发送int数据 if(btn_startSensor.getText().toString().equals("停止采集")){ PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(COUNT_PATH); putDataMapRequest.getDataMap().putInt(COUNT_KEY, count++); PutDataRequest request = putDataMapRequest.asPutDataRequest(); LOGD(TAG, "Generating DataItem: " + request); if (!mGoogleApiClient.isConnected()) { return; } Wearable.DataApi.putDataItem(mGoogleApiClient, 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()); } } }); } }
private void onLogoFetchComplete() { if (mLogo == null || mOppLogo == null) { return; } League league = new League.Builder() .account_name(DEMO_ACCOUNT.name) .league_key(DEMO_LEAGUE_KEY) .build(); Matchup matchup = new Matchup.Builder() .my_team(new Team.Builder() .score(mScore.getText().toString()) .build()) .opponent_team(new Team.Builder() .name(mOppName.getText().toString()) .score(mOppScore.getText().toString()) .build()) .build(); PutDataRequest request = LeagueData.getUpdateRequest(DEMO_ACCOUNT, league, matchup, SyncAdapter.getLogoAssetForBitmap(mLogo, mLogoSize), SyncAdapter.getLogoAssetForBitmap(mOppLogo, mLogoSize), true); Wearable.DataApi .putDataItem(mGoogleApiClient, request) .setResultCallback(new ResultCallback<DataItemResult>() { @Override public void onResult(DataItemResult dataItemResult) { Toast.makeText(DemoActivity.this, "Demo league pushed", Toast.LENGTH_SHORT) .show(); } }); mLogo = null; mOppLogo = null; }
private static void sendUpdateToWear(GoogleApiClient googleApiClient, Account account, League league, Matchup matchup, Asset logo, Asset oppLogo, boolean forceUpdate) throws IOException { PutDataRequest request = LeagueData.getUpdateRequest(account, league, matchup, logo, oppLogo, forceUpdate); DataItemResult result = Wearable.DataApi .putDataItem(googleApiClient, request) .await(Constants.GOOGLE_API_CLIENT_TIMEOUT_SEC, TimeUnit.SECONDS); if (!result.getStatus().isSuccess()) { throw new IOException("Failed to send new scores to Wear, status = " + result.getStatus()); } }
public zzr(zzmu.zzb<DataApi.DataItemResult> paramzzb) { super(); }
zzy(zzmu.zzb<DataApi.DataItemResult> paramzzb, List<FutureTask<Boolean>> paramList) { super(); this.zzzM = paramList; }
public final PendingResult<DataApi.DataItemResult> getDataItem(GoogleApiClient paramGoogleApiClient, final Uri paramUri) { paramGoogleApiClient.zza(new zzi(paramGoogleApiClient) {}); }
public final PendingResult<DataApi.DataItemResult> putDataItem(GoogleApiClient paramGoogleApiClient, final PutDataRequest paramPutDataRequest) { paramGoogleApiClient.zza(new zzi(paramGoogleApiClient) {}); }