3

I'm struggling getting this to work as expected. I need to enumerate all the activities I see in Google Fit app (e.g auto "morning walk" or manual added running). I've used the following query:

DataReadRequest readRequest = new DataReadRequest.Builder()
    .aggregate(DataType.TYPE_ACTIVITY_SEGMENT, DataType.AGGREGATE_ACTIVITY_SUMMARY)
    .enableServerQueries()
    .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
    .bucketByTime(1, TimeUnit.DAYS)
    .build();

Note: this kind of aggregation is deprecated, but I cannot find the "right" way to receive the same result with the non-deprecated method.

Now: in my example day on Fit, I've two activities. The first is auto-generated "afternoon walk" of 2.32km and 32 min, the second is a manual added running activity of 1h. The query above returns two rows with fields activity/duration/num_segments:

  1. Running / 3600000 (1h) / 1
  2. Walking / 2674044 (~44mins) / 10

As you can see I get 12 minutes added for walking, why? How can I get the exact thing I see in the app? Moreover the total sum of steps for that day is not the sum of the two activities I see on Fit. What a mess...

EDIT: about timezone I'm getting it this way:

Calendar calendar = Calendar.getInstance(Locale.getDefault());
long endTime = calendar.getTimeInMillis();
calendar.add(Calendar.MONTH, -1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
long startTime = calendar.getTimeInMillis();

And these are the results for the specific day:

DATA TYPE: DataType{com.google.activity.summary[activity(i), duration(i), num_segments(i)]}

AS ACTIVITY: running FIELD: activity(i) START TIME: Fri Oct 16 12:10:00 GMT+02:00 2020 END TIME: Fri Oct 16 13:10:00 GMT+02:00 2020


DURATION: 3600000 FIELD: duration(i) START TIME: Fri Oct 16 12:10:00 GMT+02:00 2020 END TIME: Fri Oct 16 13:10:00 GMT+02:00 2020


N. SEGMENTS: 1 FIELD: num_segments(i) START TIME: Fri Oct 16 12:10:00 GMT+02:00 2020 END TIME: Fri Oct 16 13:10:00 GMT+02:00 2020


AS ACTIVITY: walking FIELD: activity(i) START TIME: Fri Oct 16 09:20:30 GMT+02:00 2020 END TIME: Fri Oct 16 23:15:17 GMT+02:00 2020


DURATION: 2674044 FIELD: duration(i) START TIME: Fri Oct 16 09:20:30 GMT+02:00 2020 END TIME: Fri Oct 16 23:15:17 GMT+02:00 2020


N. SEGMENTS: 10 2FIELD: num_segments(i) START TIME: Fri Oct 16 09:20:30 GMT+02:00 2020 END TIME: Fri Oct 16 23:15:17 GMT+02:00 2020

Jumpa
  • 4,319
  • 11
  • 52
  • 100
  • Which package are you using? In addition, is your time range correct? – ch271828n Oct 17 '20 at 12:31
  • Take care of time-zones. Your time range may be shifted! – ch271828n Oct 17 '20 at 12:32
  • What do you mean by package? I'm not using any package. Thanks. – Jumpa Oct 17 '20 at 12:42
  • Flutter package (dependency) :) – ch271828n Oct 17 '20 at 12:43
  • I'm not using Flutter, but Java on native Android. – Jumpa Oct 17 '20 at 13:05
  • Oh sorry I just jumped between java and flutter tag so made a mistake :) Please ignore the question of "what package". So did you check time zone problem? – ch271828n Oct 17 '20 at 13:32
  • it's clear that Google Fit is not showing all activities in its app journal, nor I can somehow enumerate only the auto-generated entries via API. – Jumpa Oct 17 '20 at 15:44
  • @Jumpa, Is there any document or link to clear that Google Fit is not showing all activities in its app journal, nor I can somehow enumerate only the auto-generated entries via API. I am facing the same issue with History API, not getting the actual data for auto-generated actvities. please help me – mdroid Feb 02 '21 at 15:52
  • Jumpa, did you get any solution for this issue? – mdroid Feb 02 '21 at 15:54

0 Answers0