java.lang.Object | |
↳ | com.google.android.gms.fitness.data.Goal |
A fitness goal, which users create in Google Fit.
A goal should hold its objective, time period and activity (if any).
There are different objective types:
Goal.MetricObjective
uses a metric value to determine whether the goal is met.
Metrics include step, distance and calories. e.g. Take 10k steps.
Goal.DurationObjective
uses duration time of activities to determine whether the
goal is met. e.g. Run 30 minutes.
Goal.FrequencyObjective
uses the number of activity segments to determine whether
the goal is met. e.g. Do yoga 2x.
A goal also has a recurrence period, since users often want to "take 10k steps a day" or "do yoga 2x per week".
A goal holds different times:
Goal | Recurrence | Activity | Objective type | Objective |
---|---|---|---|---|
Run 3 times a week. | 1 week | RUNNING |
OBJECTIVE_TYPE_FREQUENCY |
Frequency: 3 |
Active 60 minutes a day. | 1 day | N/A | OBJECTIVE_TYPE_DURATION |
Duration: 60 minutes |
Take 1,000 steps a day. | 1 day | N/A | OBJECTIVE_TYPE_METRIC |
TYPE_STEP_COUNT_DELTA |
Run 2 km a week. | 1 week | RUNNING |
OBJECTIVE_TYPE_METRIC |
TYPE_DISTANCE_DELTA |
Burn 30k calories a month. | 1 month | N/A | OBJECTIVE_TYPE_METRIC |
TYPE_CALORIES_EXPENDED |
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Goal.DurationObjective | A duration objective, which uses duration time of activities to determine whether the goal is met. | ||||||||||
Goal.FrequencyObjective | A frequency objective, which uses the number of activity segments to determine whether the goal is met. | ||||||||||
Goal.MetricObjective | A metric objective, which uses a metric value to determine whether the goal is met. | ||||||||||
Goal.MismatchedGoalException | Exception thrown by getMetricObjective() , getDurationObjective() , getFrequencyObjective() if the goal doesn't match the requested objective type. |
||||||||||
Goal.ObjectiveType | Type of a goal's objective. | ||||||||||
Goal.Recurrence | A recurrence period of a recurring goal. |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | OBJECTIVE_TYPE_DURATION | Objective type constant representing a duration objective, which uses duration time of activities to determine whether the goal is met. | |||||||||
int | OBJECTIVE_TYPE_FREQUENCY | Objective type constant representing a frequency objective, which uses the number of activity segments to determine whether the goal is met. | |||||||||
int | OBJECTIVE_TYPE_METRIC | Objective type constant representing a metric objective, which uses a metric value to determine whether the goal is met. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
CREATOR |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the name of the goal's specific activity, if any.
| |||||||||||
Returns the creation time of the goal since epoch, in the specified time unit.
| |||||||||||
Returns the duration objective of the goal if the objective type is
OBJECTIVE_TYPE_DURATION . | |||||||||||
Returns the end time of the time range that should be used to calculate goal progress for
current time.
| |||||||||||
Returns the frequency objective of the goal if the objective type is
OBJECTIVE_TYPE_FREQUENCY . | |||||||||||
Returns the metric objective of the goal if the objective type is
OBJECTIVE_TYPE_METRIC . | |||||||||||
Returns the type of the goal's objective.
| |||||||||||
Returns the recurrence period of a goal if the goal is a recurring one.
| |||||||||||
Returns the start time of the time range that should be used to calculate goal progress for
current time.
| |||||||||||
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Objective type constant representing a duration objective, which uses duration time of activities to determine whether the goal is met. e.g. Run 30 minutes.
Objective type constant representing a frequency objective, which uses the number of activity segments to determine whether the goal is met. e.g. Do yoga 2x.
Objective type constant representing a metric objective, which uses a metric value to determine whether the goal is met. e.g. Take 10k steps.
Parameters | |
---|---|
that |
Object
|
Returns | |
---|---|
boolean |
Returns the name of the goal's specific activity, if any. e.g. Returns "running" for a goal "run 30km a week".
Returns | |
---|---|
String |
null if there is no specific activity for the goal. If there is no specific activity for a goal, then the goal should apply to all activities. e.g. The goal "30km a week" takes into account all activities including walking, running, biking, etc. |
Returns the creation time of the goal since epoch, in the specified time unit.
Parameters | |
---|---|
timeUnit |
TimeUnit
|
Returns | |
---|---|
long |
Returns the duration objective of the goal if the objective type is OBJECTIVE_TYPE_DURATION
.
Returns | |
---|---|
Goal.DurationObjective |
Throws | |
---|---|
Goal.MismatchedGoalException |
if the objective type of the goal is not OBJECTIVE_TYPE_DURATION
|
Returns the end time of the time range that should be used to calculate goal progress for current time. For recurring goals, end time represents the end time of the current recurrence of the goal. For non-recurring goals, the end time is the time at which user activities stop counting towards the objective.
Parameters | |
---|---|
current |
Calendar :
current time |
timeUnit |
TimeUnit :
the desired time unit for the returned end time
|
Returns | |
---|---|
long |
Returns the frequency objective of the goal if the objective type is OBJECTIVE_TYPE_FREQUENCY
.
Returns | |
---|---|
Goal.FrequencyObjective |
Throws | |
---|---|
Goal.MismatchedGoalException |
if the objective type of the goal is not OBJECTIVE_TYPE_FREQUENCY
|
Returns the metric objective of the goal if the objective type is OBJECTIVE_TYPE_METRIC
.
Returns | |
---|---|
Goal.MetricObjective |
Throws | |
---|---|
Goal.MismatchedGoalException |
if the objective type of the goal is not OBJECTIVE_TYPE_METRIC
|
Returns the type of the goal's objective. The objective type should be one of the OBJECTIVE_TYPE_METRIC
, OBJECTIVE_TYPE_DURATION
, OBJECTIVE_TYPE_FREQUENCY
constants.
Returns | |
---|---|
int |
Returns the recurrence period of a goal if the goal is a recurring one. e.g. Returns 1 week for a goal to "run 30km a week".
Returns | |
---|---|
Goal.Recurrence |
null if the goal is not recurring. |
Returns the start time of the time range that should be used to calculate goal progress for current time. This is the time from which user activities start counting towards the objective. For recurring goals, start time represents the start time of the current recurrence of the goal. For non-recurring goals, start time is the same as create time.
Parameters | |
---|---|
current |
Calendar :
current time |
timeUnit |
TimeUnit :
the desired time unit for the returned start time
|
Returns | |
---|---|
long |
Returns | |
---|---|
int |
Returns | |
---|---|
String |
Parameters | |
---|---|
dest |
Parcel
|
flags |
int
|