Chapter 9 Google Fit API

9.1 Google Fit API

The Google Fit API (also referred to simply as the Fit API) resides in the namespace com.google.android.gms.fitness and is available as part of Google Play Services. Any Google Fit App has a dependency on the Google Play Services App being installed on the device that it is running on.

9.2 Google fit main package (com.google.android.gms.fitness)

The Google Fit API documentation is available at https://developers.google.com/fit/android/reference and is a useful reference when reading this chapter.

In all, the main package fitness and its sub-packages contain about eight high-level interfaces and 30 high-level classes. The main package fitness contains four sub-packages: data, service, request, and result. The fitness package itself contains the interfaces SensorsApi, BleApi (Bluetooth Low Energy API), SensorsApi, RecordingApi, HistoryApi, and SessionsApi, as well as the classes Fitness, FitnessActivities, and FitnessStatusCodes.

Figure 9-1 shows the classes and interfaces within the main fitness package, as well as the sub-packages data, request, result, and service.

c9-fig-0001

Figure 9-1 Google Fit’s fitness package, high-level overview.

9.2.1 Fitness class

The Fitness class is the entry point into the Google Fit API. In order for a Fit App to connect to the Fit API, a Google user account is required on the device. The Fit App needs ...

Get Wearable Android: Android Wear and Google FIT App Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.