Android APIs
public static class

SessionReadRequest.Builder

extends Object
java.lang.Object
   ↳ com.google.android.gms.fitness.SessionReadRequest.Builder

Class Overview

Builder used to create new SessionReadRequest.

Summary

Public Constructors
SessionReadRequest.Builder()
Public Methods
SessionReadRequest.Builder addDataSource(DataSource dataSource)
Adds a specific data source we want data from to this request.
SessionReadRequest.Builder addDefaultDataSource(DataType dataType)
Adds the default data source for the given dataType to this request.
SessionReadRequest build()
Finishes building and returns the request.
SessionReadRequest.Builder readSessionsFromAllApps()
Adds option to read sessions from other apps.
SessionReadRequest.Builder setSessionId(String sessionId)
Adds an optional session id for the request.
SessionReadRequest.Builder setSessionName(String sessionName)
Adds an optional session name for the request.
SessionReadRequest.Builder setTimeInterval(long startTime, long endTime, TimeUnit timeUnit)
Sets the time range for our query.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public SessionReadRequest.Builder ()

Public Methods

public SessionReadRequest.Builder addDataSource (DataSource dataSource)

Adds a specific data source we want data from to this request. Either this method or addDefaultDataSource(DataType) must be called to add at least one data source to the request.

The data returned from this data source may not be necessarily inserted together with the session.

Parameters
dataSource the data source we're reading

public SessionReadRequest.Builder addDefaultDataSource (DataType dataType)

Adds the default data source for the given dataType to this request. The default data source is selected based on all available sources for the given data type, and may be averaged or filtered.

The data returned from this data source may not have been inserted together with the session.

This method can be used instead of addDataSource(DataSource) when the application is not interested in a specific data source.

Parameters
dataType the data type we are reading

public SessionReadRequest build ()

Finishes building and returns the request.

Throws
IllegalArgumentException if the builder doesn't have valid time interval data to create a read request
IllegalStateException if the builder doesn't have valid data type or data source to create a read request

public SessionReadRequest.Builder readSessionsFromAllApps ()

Adds option to read sessions from other apps. If not set, only sessions added by the calling app will be returned.

public SessionReadRequest.Builder setSessionId (String sessionId)

Adds an optional session id for the request. If not specified, all sessions in the specified time interval are returned.

Parameters
sessionId the Id of the session we want data for.

public SessionReadRequest.Builder setSessionName (String sessionName)

Adds an optional session name for the request. If not specified, all sessions in the specified time interval are returned.

Parameters
sessionName the name of the session we want data for.

public SessionReadRequest.Builder setTimeInterval (long startTime, long endTime, TimeUnit timeUnit)

Sets the time range for our query.

A defined start and time is required for every read query, even though session name and id are optional. All sessions that fall in the specified time interval and which match the other optional filters are returned. For a session to be returned, it has to fall within the interval specified in the query. Overlapping sessions with start and/or end times outside the interval will not be returned. Continuing sessions with no end time specified yet, but with start time after the query start time are also returned.

Parameters
startTime a start time since epoch, inclusive
endTime an end time since epoch, inclusive
timeUnit time unit for the start and end times.