SessionInsertRequest

public class SessionInsertRequest extends AbstractSafeParcelable

A request for inserting a Session and associated DataSet and/or aggregated DataPoint into the Google Fit store. Useful when data is read from a data source outside of Google Fit, or when inserting batch historical data.

The request cannot have a continuing session, i.e. session should have valid start and end times. Request may contain multiple data sets and multiple aggregated data points.

The Builder will enforce that each data set or aggregated data point represents a unique DataSource. The Builder will also enforce that timestamps of the data specified are consistent with session start and end times. For all data points specified in the data set(s), the timestamps should fall between the session start and end times. And for all aggregate data points, the start and end time timestamps should fall between the session start and end times.

Note: removing a session will have no impact on the data which was part of the corresponding SessionInsertRequest. To remove the data that was inserted along with a session deleteData(GoogleApiClient, DataDeleteRequest) should be used instead.

Example usage:

     Session session = new Session.Builder()
          .setName(sessionName)
          .setIdentifier(identifier)
          .setDescription(description)
          .setStartTime(startTime.getMillis(), TimeUnit.MILLISECONDS)
          .setEndTime(endTime.getMillis(), TimeUnit.MILLISECONDS)
          .build();
     SessionInsertRequest request = new SessionInsertRequest.Builder()
          .setSession(session)
          .addDataSet(dataSet)
          .addAggregatedDataPoint(dataPoint)
          .build();
 
Apps can only add data for public data types or custom data types created by itself. Data of custom data type created by another app cannot be added.

Nested Class Summary

class SessionInsertRequest.Builder Builder used to create new SessionInsertRequest. 

Inherited Constant Summary

Field Summary

public static final Creator<SessionInsertRequest> CREATOR

Public Method Summary

boolean
List<DataPoint>
getAggregateDataPoints()
Returns the aggregate data points we are inserting.
List<DataSet>
getDataSets()
Returns the data sets we are inserting.
Session
getSession()
Returns the session we are inserting.
int
String
void
writeToParcel(Parcel dest, int flags)

Inherited Method Summary

Fields

public static final Creator<SessionInsertRequest> CREATOR

Public Methods

public boolean equals (Object o)

public List<DataPoint> getAggregateDataPoints ()

Returns the aggregate data points we are inserting.

Returns
  • the list of specified data points, empty if none

public List<DataSet> getDataSets ()

Returns the data sets we are inserting.

Returns
  • the list of specified data sets, empty if none

public Session getSession ()

Returns the session we are inserting.

public int hashCode ()

public String toString ()

public void writeToParcel (Parcel dest, int flags)