我正在使用此代码来尝试检索过去 14 小时内所做的步骤。
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 返回成功,但是当我尝试将结果读入数据集时出现此错误
java.lang.IllegalArgumentException: Attempting to read data for com.google.step_count.delta, which was not requested
我尝试了各种数据类型,但每次都收到相同的错误,我做错了什么?!