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
I am in need to show steps time line wise like below.
Time 10 am - 56 steps
Time 11 am - 156 steps
Time 4.30 pm - 236 steps
I don't want to aggregate by hour or anything , i just want the actual data that is currently google fit app is showing in timeline using steps filter.
However i am able to retrieve steps using bucketBySession that entered manually into google fit app but not able to retrieve those steps history which is generated automatically.
Please let me know how to overcome this.
Below is my sample code.
// Build a session read request
SessionReadRequest readRequest = new SessionReadRequest.Builder()
.setTimeInterval(times[0], times[1], TimeUnit.MILLISECONDS)
.readSessionsFromAllApps()
.read(DataType.TYPE_STEP_COUNT_DELTA)
.enableServerQueries()
.build();
Fitness.getSessionsClient(mContext, GoogleSignIn.getLastSignedInAccount(mContext))
.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.
List<Session> sessions = sessionReadResponse.getSessions();
Log.i(TAG, "Session read was successful. Number of returned sessions is: "
+ sessions.size());
for (Session session : sessions) {
// Process the session
dumpSession(session);
// Process the data sets for this session
List<DataSet> dataSets = sessionReadResponse.getDataSet(session);
for (DataSet dataSet : dataSets) {
dumpDataSet(dataSet);
}
}
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.i(TAG, "Failed to read session");
}
});
final DataReadRequest req = new DataReadRequest.Builder()
.aggregate(DataType.TYPE_STEP_COUNT_DELTA, DataType.AGGREGATE_STEP_COUNT_DELTA)
.aggregate(DataType.TYPE_ACTIVITY_SEGMENT, DataType.AGGREGATE_ACTIVITY_SUMMARY)
.enableServerQueries()
.bucketBySession(1, TimeUnit.MINUTES)
.setTimeRange(times[0], times[1], TimeUnit.MILLISECONDS)
.build();
Fitness.getHistoryClient(mContext, GoogleSignIn.getLastSignedInAccount(mContext))
.readData(req)
.addOnSuccessListener(
dataReadResponse -> readData(dataReadResponse, MESSAGE_HEALTH_DATA_LIST_KEY))
.addOnFailureListener(
e -> {
});
I am trying with the both client , session as well as history but didn't get any suceess.
thanks,
Krunal
The text was updated successfully, but these errors were encountered:
Issue by krunal93
Monday Jul 02, 2018 at 13:53 GMT
Originally opened as googlearchive/android-fit#37
I am in need to show steps time line wise like below.
Time 10 am - 56 steps
Time 11 am - 156 steps
Time 4.30 pm - 236 steps
I don't want to aggregate by hour or anything , i just want the actual data that is currently google fit app is showing in timeline using steps filter.
However i am able to retrieve steps using bucketBySession that entered manually into google fit app but not able to retrieve those steps history which is generated automatically.
Please let me know how to overcome this.
Below is my sample code.
I am trying with the both client , session as well as history but didn't get any suceess.
thanks,
Krunal
The text was updated successfully, but these errors were encountered: