I have been trying to get GoogleFit data with buckets 15 minutes in the last 2 weeks. But for some reason, the call to HistoryApi never ends, even if I wait a few minutes. When using 1 hour buckets, it returns pretty quickly. Are there any restrictions that I just did not see?
My plan would be to get 15 minute buckets in the last year or so, but if even 2 weeks of work it would be a problem ...
What I still have: I installed my GoogleApi client as follows:
mClient = new GoogleApiClient.Builder(mContext) .addApi(Fitness.SENSORS_API) .addApi(Fitness.HISTORY_API) .addScope(new Scope(FITNESS_ACTIVITY_READ)) .addConnectionCallbacks( new GoogleApiClient.ConnectionCallbacks() { @Override public void onConnected(Bundle bundle) { fetchHistoryData(); } @Override public void onConnectionSuspended(int i) {
And then I try to extract the data as follows:
final DataReadRequest readRequest = new DataReadRequest.Builder() .aggregate(DataType.TYPE_STEP_COUNT_DELTA, DataType.AGGREGATE_STEP_COUNT_DELTA) .aggregate(DataType.TYPE_CALORIES_EXPENDED, DataType.AGGREGATE_CALORIES_EXPENDED) .bucketByTime(1, TimeUnit.HOURS) .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS) .build(); Fitness.HistoryApi.readData(mClient, readRequest).setResultCallback(new ResultCallback<DataReadResult>() { @Override public void onResult(@NonNull DataReadResult dataReadResult) { handleGoogleFitData(dataReadResult); } });
which works fine, but when I go ahead and change the bucket time to .bucketByTime(15, TimeUnit.MINUTES) , my onResult will never be called. I also noticed the same thing, having 1 hour intervals and returning for 1 year.
Is this a limitation of Google Fit? At least I did not find any documentation about such a limit ...
I also sometimes get a request callback quickly, sometimes it just never returns. Any ideas on this?
android google-fit google-fit-sdk
Georg
source share