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();
See also:
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)
Parameters | |
---|---|
o |
Object
|
Returns | |
---|---|
boolean |
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.
Parameters | |
---|---|
intent |
Intent
|
Returns | |
---|---|
Session |
the extracted Session, or 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.
Parameters | |
---|---|
timeUnit |
TimeUnit
|
Returns | |
---|---|
long |
Throws | |
---|---|
IllegalStateException |
hasActiveTime() returns false .
|
Returns the activity associated with this session, if set. Else returns
UNKNOWN
.
Returns | |
---|---|
String |
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 | |
---|---|
String |
Returns the description for this session, if set.
Returns | |
---|---|
String |
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.
Parameters | |
---|---|
timeUnit |
TimeUnit
|
Returns | |
---|---|
long |
Returns the identifier for this session, if set.
Returns | |
---|---|
String |
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.
Parameters | |
---|---|
activity |
String :
one of the activities in FitnessActivities .
|
Returns | |
---|---|
String |
Returns the name for this session. A non-empty name is always set.
Returns | |
---|---|
String |
Returns the start time for the session, in the given time unit since epoch. A valid start time is always set.
Parameters | |
---|---|
timeUnit |
TimeUnit
|
Returns | |
---|---|
long |
Returns whether the session active time is set.
Returns | |
---|---|
boolean |
Returns | |
---|---|
int |
Returns whether the session is ongoing. If the session has ended, this will return false.
Returns | |
---|---|
boolean |
Returns | |
---|---|
String |
Parameters | |
---|---|
dest |
Parcel
|
flags |
int
|