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) .setStartTime(startTime, TimeUnit.MILLISECONDS) .setEndTime(endTime, TimeUnit.MILLISECONDS) .setActivity(FitnessActivities.BIKING) .build();
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Session.Builder | Builder used to create new Sessions. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | EXTRA_SESSION | Name for the parcelable intent extra containing a session. | |||||||||
String | MIME_TYPE_PREFIX | The common prefix for session MIME types. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Extracts the session extra from the given intent, such as a callback intent received
after
registering
to session start/end notifications, or an intent to
view a session.
| |||||||||||
Returns the active time period of the session.
| |||||||||||
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 the given unit since epoch.
| |||||||||||
Returns the identifier for this session, if set.
| |||||||||||
Returns the MIME type which describes a Session for a particular activity.
| |||||||||||
Returns the name for this session.
| |||||||||||
Returns the start time for the session, in the given time unit since epoch.
| |||||||||||
Returns whether the session active time is set.
| |||||||||||
Returns whether the session is ongoing.
| |||||||||||
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Name for the parcelable intent extra containing a session. It can be
extracted using extract(Intent)
.
The common prefix for session MIME types. The MIME type for a particular session will be this prefix followed by the session's activity name. Examples:
vnd.google.fitness.session/running vnd.google.fitness.session/volleyball.beachThe session's activity type is returned by
getActivity()
. The MIME
type can be computed from the activity using getMimeType(String)
Extracts the session extra from the given intent, such as a callback intent received after registering to session start/end notifications, or an intent to view a session.
null
if the given intent does not contain a
Session
Returns the active time period of the session.
Make sure to use hasActiveTime()
before using this method.
IllegalStateException | hasActiveTime() returns false .
|
---|
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 end time for the session, in the given unit since epoch. If the session is ongoing (it hasn't ended yet), this will return 0.
Returns the MIME type which describes a Session for a particular activity. The MIME type is used in intents such as the session view intent.
activity | one of the activities in FitnessActivities .
|
---|
Returns the start time for the session, in the given time unit since epoch. A valid start time is always set.
Returns whether the session active time is set.
Returns whether the session is ongoing. If the session has ended, this will return false.