Work with Fitness Goals

Goals provide a way for Google Fit users to track their health and fitness progress. The Goals API enables your app to read user goals, and use this data to enhance the user's experience by providing updates and insights related to the user's progress.

Read goals data

To get a list of user goals:

The following example shows creating a new Fitness client and getting a list of user goals for TYPE_STEP_COUNT_DELTA and TYPE_DISTANCE_DELTA data types:

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

Once you've got the user's goals data, you can use the History API to query for progress. The following example demonstrates reading the user's step data and calculating their current progress toward their step goal (it is assumed that your app has already used the Recording API to subscribe to the TYPE_STEP_COUNT_DELTA data type):

Calendar current = Calendar.getInstance();

DataReadRequest readRequest = new DataReadRequest.Builder()
        goal.getStartTime(current, TimeUnit.NANOSECONDS),
        goal.getEndTime(current, TimeUnit.NANOSECONDS),

Task<DataReadResponse> response = Fitness.getHistoryClient(this,