java.lang.Object | |
↳ | com.google.android.gms.fitness.data.Session |
A Session represents a time interval with associated metadata. Sessions provide a mechanism to store user-visible groups of related stream data in a useful and shareable manner, and allows for easy querying of the data in a detailed or aggregated fashion. The start and end times for sessions will be controlled by applications, and can be used to represent user-friendly groupings of activities, such as "bike ride", "marathon training run", etc. Any data in Google Fit which falls within this time range is implicitly associated with the session.
A session consists of the following fields:
Example usage:
new Session.Builder() .setName(sessionName) .setIdentifier(identifier) .setDescription(description) .setStartTimeMillis(startTime.getMillis()) .setEndTimeMillis(endTime.getMillis()) .setActivity(FitnessActivities.BIKING) .build();
Nested Classes | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Session.Builder | Builder used to create new Sessions. |
[Expand]
Inherited Constants | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
![]()
| |||||||||||||||||
![]()
|
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
CREATOR |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Extracts a session from a callback intent received after registering to session start/end
notifications with a PendingIntent.
| |||||||||||
Returns the activity associated with this session, if set.
| |||||||||||
Returns the package name for the application responsible for adding the session.
| |||||||||||
Returns the description for this session, if set.
| |||||||||||
Returns the end time for the session, in milliseconds since epoch.
| |||||||||||
Returns the identifier for this session, if set.
| |||||||||||
Returns the name for this session.
| |||||||||||
Returns the start time for the session, in milliseconds since epoch.
| |||||||||||
Returns whether the session is ongoing.
| |||||||||||
[Expand]
Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||||||||||||||||||||||||
![]() |
Extracts a session from a callback intent received after registering to session start/end notifications with a PendingIntent.
null
if the given intent does not contain a
Session
Returns the activity associated with this session, if set. Else returns
UNKNOWN
.
Returns the package name for the application responsible for adding the session.
or null
if unset/unknown. The PackageManager
can be used to query
relevant data on the application, such as the name, icon, logo, etc.
Returns the description for this session, if set.
Returns the end time for the session, in milliseconds since epoch. If the session is ongoing (it hasn't ended yet), this will return 0.
Returns the identifier for this session, if set.
Returns the name for this session. A non-empty name is always set.
Returns the start time for the session, in milliseconds since epoch. A valid start time is always set.
Returns whether the session is ongoing. If the session has ended, this will return false.