public class

FitnessIntents

extends Object
java.lang.Object
   ↳ com.google.android.gms.fitness.FitnessIntents

Class Overview

Useful constants and methods for dealing with intents in the Fitness platform.

Summary

Constants
String ACTION_TRACK Broadcast action: the user has requested that an application starts or stops tracking their activity.
String ACTION_VIEW Broadcast action: the user has requested that an application show the value of a particular fitness data type.
String ACTION_VIEW_GOAL Broadcast action: the user has requested to view their current fitness goal.
String EXTRA_DATA_SOURCE Name for the optional parcelable intent extra containing the data source.
String EXTRA_END_TIME Name for the optional long intent extra containing the end time in milliseconds since epoch.
String EXTRA_SESSION Name for the parcelable intent extra containing the data session.
String EXTRA_START_TIME Name for the optional long intent extra containing the start time in milliseconds since epoch.
String EXTRA_STATUS Name for the String extra containing the status of an activity.
String MIME_TYPE_ACTIVITY_PREFIX The common prefix for Activity types.
String MIME_TYPE_DATA_TYPE_PREFIX The common prefix for Fitness data type MIME types.
String MIME_TYPE_SESSION_PREFIX The common prefix for Session MIME types.
String STATUS_ACTIVE Status indicating the activity has started.
String STATUS_COMPLETED Status indicating the activity has ended.
Public Methods
static String getActivityMimeType(int activity)
Returns the MIME type for a particular activity.
static DataSource getDataSource(Intent intent)
Retrieves the data source extra from the given intent.
static String getDataTypeMimeType(DataType dataType)
Returns the MIME type for a particular DataType.
static long getEndTime(Intent intent)
Retrieves the end time extra from the given intent.
static String getSessionMimeType(int activity)
Returns the MIME type which describes a Session for a particular activity.
static long getStartTime(Intent intent)
Retrieves the start time extra from the given intent.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String ACTION_TRACK

Broadcast action: the user has requested that an application starts or stops tracking their activity. The intent will include the following attributes:

  • mimeType: this will be MIME_TYPE_ACTIVITY_PREFIX followed by the name of the activity. Apps can use a mimeType filter to listen only on activities they can track.
  • Extra EXTRA_STATUS: an extra indicating the current status of the activity (active or completed).

Constant Value: "vnd.google.fitness.TRACK"

public static final String ACTION_VIEW

Broadcast action: the user has requested that an application show the value of a particular fitness data type. This could be an intent to visualize the current value of a data type (such as the current heart rate), or the value of a data type over a period of time. The extras will determine what the particular intent is.

The intent will include the following attributes:

  • mimeType: this will be MIME_TYPE_DATA_TYPE_PREFIX followed by the name of the data type the user would like to visualize. Apps can use a mimeType filter to listen only on data types they can visualize. The MIME type can be generated by getActivityMimeType(int).
  • Extra EXTRA_START_TIME: an extra indicating the start time in milliseconds since epoch, present if the user desires to visualize data over a period of time. The start time can be extracted by getStartTime(android.content.Intent).
  • Extra EXTRA_END_TIME: an extra indicating the end time in milliseconds since epoch, present if the user desires to visualize data over a period of time. If end time isn't specified, but start time is, then the end time used should be "now". The end time can be extracted by getEndTime(android.content.Intent).

Constant Value: "vnd.google.fitness.VIEW"

public static final String ACTION_VIEW_GOAL

Broadcast action: the user has requested to view their current fitness goal.

Constant Value: "vnd.google.fitness.VIEW_GOAL"

public static final String EXTRA_DATA_SOURCE

Name for the optional parcelable intent extra containing the data source. It can be extracted using getDataSource(android.content.Intent).

Constant Value: "vnd.google.fitness.data_source"

public static final String EXTRA_END_TIME

Name for the optional long intent extra containing the end time in milliseconds since epoch. It can be extracted using getEndTime(android.content.Intent)

Constant Value: "vnd.google.fitness.end_time"

public static final String EXTRA_SESSION

Name for the parcelable intent extra containing the data session. It can be extracted using extract(android.content.Intent).

Constant Value: "vnd.google.fitness.session"

public static final String EXTRA_START_TIME

Name for the optional long intent extra containing the start time in milliseconds since epoch. It can be extracted using getStartTime(android.content.Intent).

Constant Value: "vnd.google.fitness.start_time"

public static final String EXTRA_STATUS

Name for the String extra containing the status of an activity. This is a mandatory extra for ACTION_TRACK intents, and holds one of the following values:

Constant Value: "actionStatus"

public static final String MIME_TYPE_ACTIVITY_PREFIX

The common prefix for Activity types. The MIME type for a particular activity type will be this prefix followed by the activity name.

The names for all activities are described in FitnessActivities. The MIME type can be computed from the activity's int constant using getActivityMimeType(int)

Constant Value: "vnd.google.fitness.activity/"

public static final String MIME_TYPE_DATA_TYPE_PREFIX

The common prefix for Fitness data type MIME types. The MIME type for a particular data type will be this prefix followed by the data type name.

Constant Value: "vnd.google.fitness.data_type/"

public static final String MIME_TYPE_SESSION_PREFIX

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.

The session's activity type is returned by getActivity(). The MIME type can be computed from the activity type using getSessionMimeType(int)

Constant Value: "vnd.google.fitness.session/"

public static final String STATUS_ACTIVE

Status indicating the activity has started.

Constant Value: "ActiveActionStatus"

public static final String STATUS_COMPLETED

Status indicating the activity has ended.

Constant Value: "CompletedActionStatus"

Public Methods

public static String getActivityMimeType (int activity)

Returns the MIME type for a particular activity.

Parameters
activity one of the activities in FitnessActivities.

public static DataSource getDataSource (Intent intent)

Retrieves the data source extra from the given intent.

Returns
  • the data source, or null if not found

public static String getDataTypeMimeType (DataType dataType)

Returns the MIME type for a particular DataType.

public static long getEndTime (Intent intent)

Retrieves the end time extra from the given intent.

Returns
  • the end time, in milliseconds since epoch, or -1 if not found

public static String getSessionMimeType (int activity)

Returns the MIME type which describes a Session for a particular activity.

Parameters
activity one of the activities in FitnessActivities.

public static long getStartTime (Intent intent)

Retrieves the start time extra from the given intent.

Returns
  • the start time, in milliseconds since epoch, or -1 if not found