SessionReadResponse

public class SessionReadResponse extends Response<SessionReadResult>

Result of readSession(com.google.android.gms.fitness.request.SessionReadRequest). Contains all Sessions and their corresponding data sets that matched the filters specified in the SessionReadRequest.

The method getStatus() can be be used to confirm if the request was successful.

In case the calling app is missing the required permissions, the returned status has status code set to NEEDS_OAUTH_PERMISSIONS. In this case the caller should use startResolutionForResult(Activity, int) to start an intent to get the necessary consent from the user before retrying the request.

The method getSessions() returns all sessions that are returned for the request. The method getDataSet(Session, DataType) returns DataSet for a particular Session and DataType from the result.

In case the app tried to read data for a custom data type created by another app, the returned status has status code set to INCONSISTENT_DATA_TYPE.

Protected Constructor Summary

Public Method Summary

List<DataSet>
getDataSet(Session session, DataType dataType)
Returns the data sets for a given session and dataType.
List<DataSet>
getDataSet(Session session)
Returns the data sets for all data sources for a given session.
List<Session>
getSessions()
Returns all sessions that matched the requested filters.
Status

Inherited Method Summary

Protected Constructors

protected SessionReadResponse (SessionReadResult originalResult)

Public Methods

public List<DataSet> getDataSet (Session session, DataType dataType)

Returns the data sets for a given session and dataType. If a specific data source was requested for this data type in the read request, the returned data set is from that source. Else, the default data source for this data type is used. Returns empty if no data for the requested data type is found.

Returns
  • data sets for the given session and data type, empty if no data was found. Multiple data sets may be returned for a given type, based on the read request
Throws
IllegalArgumentException if the given session was not part of getSessions() output.

public List<DataSet> getDataSet (Session session)

Returns the data sets for all data sources for a given session. If a specific data source was requested for a data type in the read request, the returned data set is from that source. Else, the default data source for the requested data type is used.

Returns
  • data sets for the given session for all data sources, empty if no data was found. Multiple data sets may be returned for a given type, based on the read request
Throws
IllegalArgumentException if the given session was not part of getSessions() output

public List<Session> getSessions ()

Returns all sessions that matched the requested filters.

public Status getStatus ()