Stay organized with collections Save and categorize content based on your preferences.
public class GoalsClient extends GoogleApi<Api.ApiOptions.HasGoogleSignInAccountOptions>

This class is deprecated.
For reading and writing historical fitness data use Health Connect.

Client for reading fitness Goals created by users in Google Fit.

The readCurrentGoals(GoalsReadRequest) method should be used whenever goals are needed.

The Goals Client should be accessed via the Fitness entry point. Example:

    GoogleSignInOptionsExtension fitnessOptions =
            .addDataType(DataType.TYPE_STEP_COUNT_DELTA, FitnessOptions.ACCESS_READ)
            .addDataType(DataType.TYPE_DISTANCE_DELTA, FitnessOptions.ACCESS_READ)

    GoogleSignInAccount googleSignInAccount =
        GoogleSignIn.getAccountForExtension(this, fitnessOptions);

    Task<List<Goal>> response = Fitness.getGoalsClient(this, googleSignInAccount)
        .readCurrentGoals(new GoalsReadRequest.Builder()

    List<Goal> goals = Tasks.await(response);

This Client can be combined with a subscription in the Recording Client to collect goal progress data in the background and query it later for displaying. A simple progress query example for a step metric goal:

    Calendar current = Calendar.getInstance();
    Task<DataReadResponse> response = Fitness.getHistoryClient(this, googleSignInAccount)
        .readData(new DataReadRequest.Builder()
                goal.getStartTime(current, TimeUnit.NANOSECONDS),
                goal.getEndTime(current, TimeUnit.NANOSECONDS),
    DataReadResponse stepReadResponse = Tasks.await(response);
    List<DataPoint> dataPoints =

    int total = 0;
    for (DataPoint dataPoint : dataPoints) {
      total += dataPoint.getValues()[0].asInt();
    double progress = total / goal.getMetricObjective().getValue();

Public Method Summary

readCurrentGoals(GoalsReadRequest request)
Reads current goals from the user's Google Fit store.

Inherited Method Summary

Public Methods

public Task<List<Goal>> readCurrentGoals (GoalsReadRequest request)

Reads current goals from the user's Google Fit store.

  • Task containing current goals.