Tuesday 20 October 2020

Fetch Google Fit history same way Google Fit app does (Google Fit auto recorded activities)

I'm trying hard to display same history of activities as Google Fit app does. I do just fine with sessions, but I just can't grasp the auto-recorded activities properly. Like these two top walks in the example.

enter image description here

I think everything goes down to the way DataReadRequest is built. The closest I got is:

DataReadRequest.Builder()
                            .aggregate(DataType.TYPE_ACTIVITY_SEGMENT, DataType.AGGREGATE_ACTIVITY_SUMMARY)
                            .bucketByActivitySegment(5, TimeUnit.MINUTES)
                            .setTimeRange(dateFrom.millis, dateTo.millis, TimeUnit.MILLISECONDS)
                            .build()

Intentionally excluded shorter than 5 walks. Results are similar, but the outcome varies a bit. Around 20% less duration and kcal. Sometimes it really goes bananas tho, cutting activities in a small pieces. I have 2 walks in Google fit and end up in 4 walks in my app, which don't add up to the 2 from Google Fit. I tried to decompile Google Fit app to "borrow" request setup, but the app is obfuscated well. :)

Did any one achieve it?



from Fetch Google Fit history same way Google Fit app does (Google Fit auto recorded activities)

No comments:

Post a Comment