Class AggregateQuery

java.lang.Object
com.codename1.health.AggregateQuery

public final class AggregateQuery extends Object

Describes a bucketed summary read against HealthStore.

AggregateQuery q = new AggregateQuery()
        .addType(HealthDataType.STEPS)
        .addMetric(AggregateMetric.TOTAL)
        .setTimeRange(HealthTimeRange.calendarDays(7, TimeZone.getDefault()))
        .setBucket(HealthInterval.calendarDays(1, TimeZone.getDefault()));
Totals are not comparable across platforms

When a phone and a watch both record steps for the same walk, the store holds two overlapping sets of samples. HealthKit de-duplicates them in its statistics engine; Health Connect does not. The same query against the same person can therefore return roughly double on Android.

This API does not paper over that with a heuristic de-duplicator -- guessing which of two overlapping sources is authoritative is exactly the kind of silent wrongness health data cannot afford. Use addSource(String) to pin the query to the source you trust, and tell the user which device a figure came from.

  • Constructor Details

    • AggregateQuery

      public AggregateQuery()
  • Method Details