I am trying to get GoogleFit data with buckets of 15 minutes for the last 2 weeks. But for some reason the call to the HistoryApi
does never finish, even if I wait some minutes. When using 1 hour buckets, it returns pretty fast.
Are there any limitations I just didn't see?
My plan would be to get 15 minute buckets for the last year or so, but if not even 2 weeks work that's going to be a problem...
What I have so far: I set up my GoogleApi Client like this:
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) {
// Here I'll handle that case
}
}
)
.enableAutoManage(mContext, 0, new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(ConnectionResult result) {
//Here I'll handle that case
}
})
.build();
And then I try to fetch data like this:
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 perfectly fine, but when I go ahead and change the bucket time to .bucketByTime(15, TimeUnit.MINUTES)
my onResult will never get called.
I also noticed the same when having 1 hour intervals and going back 1 year.
Is this a limitation of Google-Fit? I at least didn't find any documentation about a limit like this...
I also sometimes get a callback of a query fast, sometimes it just won't ever return. Any ideas about that?