3

I want to fetch/read data from health app. Using HealthDataResolver.AggregateRequest to read different data value like total stepCounts and distance.

Below is the working code and I am getting total step count between startTime and endTime.

HealthDataResolver.AggregateRequest request = new HealthDataResolver.AggregateRequest.Builder()
                    .setDataType(HealthConstants.StepCount.HEALTH_DATA_TYPE)
                    .addFunction(HealthDataResolver.AggregateRequest.AggregateFunction.SUM, HealthConstants.StepCount.COUNT, ALIAS_TOTAL_COUNT)
                    .setTimeGroup(HealthDataResolver.AggregateRequest.TimeGroupUnit.DAILY, 1, HealthConstants.StepCount.START_TIME,
                            HealthConstants.StepCount.TIME_OFFSET, ALIAS_BINNING_TIME)
                    .setLocalTimeRange(HealthConstants.StepCount.START_TIME, HealthConstants.StepCount.TIME_OFFSET,
                            startTime, endTime)
                    .setSort(ALIAS_BINNING_TIME, HealthDataResolver.SortOrder.ASC)
                    .build();

Now the question is I want to get distance and calories burnt by ideal time/activity. Not any calories burnt by any Exercise or Steps. See this screenshot of app, the desired data is boxed and underlined.

So to read distance and calories burnt by ideal time/activity, how to construct AggregateRequest ? OR Is there any calculations?

Help will be appreciated.

Naitik Soni
  • 700
  • 8
  • 16
  • Could you elaborate more on the words _ideal time/activity_? What does _ideal_ means? – R. Zagórski Jul 24 '19 at 10:20
  • Ideal time/activity means, amount of calories burnt doing nothing. Samsung Health keeps adding calories every minute (depending upon user data like height, weight and age). They believes that human being burns calories when they are alive (for breathing and heart operations etc). So I want to fetch that data/calories count from SDK. You can see attached screenshot of SH app. – Naitik Soni Jul 25 '19 at 05:43

2 Answers2

1

From wiki

The metabolic equivalent of task (MET) is the objective measure of the ratio of the rate at which a person expends energy, relative to the mass of that person, while performing some specific physical activity compared to a reference, set by convention at 3.5 ml of oxygen per kilogram per minute, which is roughly equivalent to the energy expended when sitting quietly.

You can use one of these Metabolic Rate Formulas

The Revised Harris-Benedict Equation

Men BMR = 88.362 + (13.397 x weight in kg) + (4.799 x height in cm) - (5.677 x age in years)

Women BMR = 447.593 + (9.247 x weight in kg) + (3.098 x height in cm) - (4.330 x age in years)

Community
  • 1
  • 1
shb
  • 5,957
  • 2
  • 15
  • 32
  • I have already tried these formulas, but still I can't get exact amount of calories burnt as compare to an app. So I am still looking for something from SDK - methods or query. Thanks btw. – Naitik Soni Jul 29 '19 at 05:53
  • 1
    Got the exact calories burnt, I was using old Harris-Benedict Equation. Thanks sir. It helped. – Naitik Soni Jul 29 '19 at 06:47
  • And please do comment here, if you found any method OR query from SDK itself. – Naitik Soni Jul 29 '19 at 07:19
1

You can check keisan this website and calculate according to your needs.

  • I am more interested in reading/fetching same data value from SDK than calculating. I know this is the way, but the calculated data is not same as theirs, and I want exact that value. – Naitik Soni Jul 29 '19 at 06:00