'When setTimeRange is large and bucketByTime is short in DataReadRequest of Google fit history Api, getting error "gms.common.api.ApiException: 5022"
I am trying to read all data from the Google fitness store, but when the "setTimeRange" is large ie: i am trying to get all data and the "bucketByTime" is in small range ie: bucketByTime(5, TimeUnit.MINUTES), I am getting the exception "There was an error reading data from Google Fit com.google.android.gms.common.api.ApiException: 5022: Cannot bucket into more than 86400 intervals."
Calendar cal = Calendar.getInstance();
Date now = new Date();
cal.setTime(now);
long endTime = cal.getTimeInMillis();
calendar.add(Calendar.YEAR, -1);
long startTime = calendar.getTimeInMillis();
DataReadRequest readRequest = new DataReadRequest.Builder()
.read(HealthDataTypes.TYPE_BLOOD_PRESSURE)
.read(DataType.TYPE_HEART_RATE_BPM)
.read(HealthDataTypes.TYPE_OXYGEN_SATURATION)
.bucketByTime(5, TimeUnit.MINUTES)
.setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
.enableServerQueries()
.build();
How can I get all data in the google fitness store??
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|