Reputation: 11
I am trying to fetch step count data of last week or last 7 days. I am getting the empty list of bucket which holds the data.
//Check how many steps were walked and recorded in the last 7 days
DataReadRequest readRequest = 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 = Fitness.HistoryApi.readData(mGoogleApiClient, readRequest).await(1, TimeUnit.MINUTES);
Upvotes: 0
Views: 60
Reputation: 36
the first you should check the fit app has data in that range date, and use same google account with your app. To enable querying the Google Fit server to fetch query results, in case the local store doesn't have data for the full requested time range.
DataReadRequest.Builder().enableServerQueries()
I'm using Fitness.getHistoryClient(params).readData()
and pass the GoogleSignIn account.
Upvotes: 0