I am using this code to try and retrieve steps made in the last 14 hours.
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);
My datareadresult returns success but when I try and read the results into the dataset I get this error
java.lang.IllegalArgumentException: Attempting to read data for com.google.step_count.delta, which was not requested
I have tried all manner of DataTypes but receive the same error everytime, what am I doing wrong?!
For anyone else that gets frustrated over this :)