3
我使用此代碼嘗試檢索過去14小時內完成的步驟。檢索Google適合步驟時出錯
YApp myApp = (mYApp) ctx;
mGoogleApiClient = myApp.getMyUser();
mGoogleApiClient.reconnect();
Calendar cal = Calendar.getInstance();
Date now = new Date();
cal.setTime(now);
long endTime = cal.getTimeInMillis();
cal.add(Calendar.HOUR_OF_DAY, -16);
long startTime = cal.getTimeInMillis();
PendingResult<DataReadResult> pendingResult =
Fitness.HistoryApi.readData(mGoogleApiClient, new DataReadRequest.Builder()
.aggregate(DataType.TYPE_STEP_COUNT_DELTA, DataType.AGGREGATE_STEP_COUNT_DELTA)
.bucketByTime(1, TimeUnit.DAYS)
.setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
.build());
DataReadResult dataReadResult = pendingResult.await();
DataSet ds = dataReadResult.getDataSet(DataType.AGGREGATE_STEP_COUNT_DELTA);
我datareadresult返回成功,但是當我嘗試讀取結果到DataSet我得到這個錯誤
java.lang.IllegalArgumentException: Attempting to read data for com.google.step_count.delta, which was not requested
我已經嘗試了數據類型的所有方式,但收到同樣的錯誤,每次,我是什麼做錯了?!
中獲取你是我的英雄! :d – seahorsepip 2015-03-07 13:30:03