Google Fit API not returning activities from last 90 days

72
May 01, 2022, at 11:10 PM

I'm trying to retrieve the Google Fit activities from the last 90 days, but it is not returning all the activities.

This is the date range:

  • Start date = today - 90 days = Nov/09/2021 00:00:00
  • End date = today = Feb/07/2022 00:00:00

Today I inserted some activities in Nov/09/2021, but the API is not retrieving them. Is there any limit to the time range? I could not find anything in the documentation.

Code sample:

final DataReadRequest req = new DataReadRequest.Builder()
        .aggregate(DataType.TYPE_ACTIVITY_SEGMENT, DataType.AGGREGATE_ACTIVITY_SUMMARY)
        .enableServerQueries()
        .bucketBySession(1, TimeUnit.SECONDS)
        .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
        .build();
Fitness.getHistoryClient(mContext, GoogleSignIn.getLastSignedInAccount(mContext))
        .readData(req)
        .addOnSuccessListener(dataReadResponse -> {
            if (dataReadResponse.getStatus().isSuccess()) {
                // read response data
            }
        });

EDIT: Apparently setTimeRange filters by the activity creation date, not the date I set in Google Fit. I did a test with an account that had activities at November 09 (inserted in the past on that day) and they were returned by the API.

Rent Charter Buses Company
READ ALSO
OnActivityResult method is deprecated, what is the alternative?

OnActivityResult method is deprecated, what is the alternative?

I recently discovered that onActivityResult is deprecatedWhat should we do to handle it?

164
Is Main/UI Thread same as System UI Thread in Android?

Is Main/UI Thread same as System UI Thread in Android?

This question is different than what's being discussed about Main thread and UI thread in Android

131
how to automatic connect to device via Bluetooth and send file in flutter?

how to automatic connect to device via Bluetooth and send file in flutter?

how can write a program to connect nearly devices automatically via Bluetooth and send a file? just tried with FlutterBlue package but it doesn't work

120
Xamarin Dependency Services does not work with higher Android version

Xamarin Dependency Services does not work with higher Android version

I have programmed a Xamarin app that uses a native Android function through Dependency ServiceSpecifically it is about WifiManager and the method SetWifiEnabled() which is for turning off Wifi

88