There are varying examples of retrieving a list (buckets) of daily step counts for a range of dates, but I'm not sure which approach is best. I've seen an example like the following:
val dSource = DataSource.Builder()
.setAppPackageName("com.google.android.gms")
.setDataType(DataType.TYPE_STEP_COUNT_DELTA)
.setType(DataSource.TYPE_DERIVED)
.setStreamName("estimated_steps")
.build()
val request = DataReadRequest.Builder()
.aggregate(dSource)
.bucketByTime(1, TimeUnit.DAYS)
.setTimeRange(startDateInMs, endDateInMs, TimeUnit.MILLISECONDS)
.build()
I've also seen an example exactly like the above but instead of: .aggregate(dSource) it is .aggregate(dSource, DataType.AGGREGATE_STEP_COUNT_DELTA). What does the 2nd parameter accomplish?
Then in the official Google Fit documentation about reading historical data they omit the entire portion concerning the estimated steps datasource builder and their .aggregate call is .aggregate(DataType.AGGREGATE_STEP_COUNT_DELTA).
Essentially for a starting date and an ending date I want to return data (List<Map<String, Any>>) like:
[
{'date': 'Some ISO8601 Date String', 'steps': 13537},
{'date': 'Some ISO8601 Date String', 'steps': 3635},
{'date': 'Some ISO8601 Date String', 'steps': 7365},
]
I'm still unsure of the differences between TYPE_STEP_COUNT_DELTA and AGGREGATE_STEP_COUNT_DELTA and why in one example both were sent to an .aggregate call.