Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a limit on SessionReadRequest with dataSets? #31

Open
codingjeremy opened this issue Sep 10, 2019 · 2 comments
Open

Is there a limit on SessionReadRequest with dataSets? #31

codingjeremy opened this issue Sep 10, 2019 · 2 comments
Labels
migrated googlesamples Migrated from old googlesamples repos

Comments

@codingjeremy
Copy link
Contributor

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.

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]
    }
@codingjeremy codingjeremy added the migrated googlesamples Migrated from old googlesamples repos label Sep 18, 2019
@ItsReddi
Copy link

ItsReddi commented May 7, 2020

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

@szeidner
Copy link

Any update to this issue. I've been facing this issue as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
migrated googlesamples Migrated from old googlesamples repos
Projects
None yet
Development

No branches or pull requests

3 participants