You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to use SessionReadRequest to parse data from 1 month it does not return anything. In the beginning this worked, but as newer sessions now include TYPE_HEART_RATE_BPM dataType it doesn't work anymore. When I don't read this dataType or lower the time to only 3 days back in time it works.. Could anyone help me with this issue. Is there some sort on limit on a SessionReadRequest? Below is my code for reading the sessions. Once a session is read is goes to the populateList where they are added to a list and when completed notify a RecyclerView.
private SessionReadRequest readFitnessSession() {
// [START build_read_session_request]
// Set a start and end time for query, using a start time of 1 month before this moment.
Calendar cal = Calendar.getInstance();
Date now = new Date();
cal.setTime(now);
long endTime = cal.getTimeInMillis();
cal.add(Calendar.MONTH, -1);
long startTime = cal.getTimeInMillis();
// Build a session read request
SessionReadRequest readRequest = new SessionReadRequest.Builder()
.setTimeInterval(startTime, endTime, TimeUnit.MILLISECONDS)
.read(DataType.TYPE_HEART_RATE_BPM)
.read(DataType.AGGREGATE_DISTANCE_DELTA)
.readSessionsFromAllApps()
//.enableServerQueries()
.build();
// [END build_read_session_request]
return readRequest;
}
private Task<SessionReadResponse> readSession() {
// Begin by creating the query.
SessionReadRequest readRequest = readFitnessSession();
// [START read_session]
// Invoke the Sessions API to fetch the session with the query and wait for the result
// of the read request. Note: Fitness.SessionsApi.readSession() requires the
// ACCESS_FINE_LOCATION permission.
return Fitness.getSessionsClient(this, GoogleSignIn.getLastSignedInAccount(this))
.readSession(readRequest)
.addOnSuccessListener(new OnSuccessListener<SessionReadResponse>() {
@Override
public void onSuccess(SessionReadResponse sessionReadResponse) {
// Get a list of the sessions that match the criteria to check the result.
Log.i(TAG, "Session read was successful");
populateList(sessionReadResponse);
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.i(TAG, "Failed to read session");
}
});
// [END read_session]
}
The text was updated successfully, but these errors were encountered:
We are facing the same issue, once you have a bunch of data the listeners are not called ever again.
Is there any suitable solution?
We are facing the issue with one week data, 1 session per day.. that is not really a huge amount of data
Issue by casman51
Tuesday May 21, 2019 at 10:04 GMT
Originally opened as googlearchive/android-fit#51
When I try to use SessionReadRequest to parse data from 1 month it does not return anything. In the beginning this worked, but as newer sessions now include TYPE_HEART_RATE_BPM dataType it doesn't work anymore. When I don't read this dataType or lower the time to only 3 days back in time it works.. Could anyone help me with this issue. Is there some sort on limit on a SessionReadRequest? Below is my code for reading the sessions. Once a session is read is goes to the populateList where they are added to a list and when completed notify a RecyclerView.
The text was updated successfully, but these errors were encountered: