Recording Fitness Data

The Recording API enables your app to request automated storage of sensor data in a battery- efficient manner by creating subscriptions. A subscription is associated with an Android app and consists of a fitness data type or a specific data source.

You can create multiple subscriptions for different data types or data sources in your app. Google Fit stores fitness data from active subscriptions even when your app is not running and restores these subscriptions when the system restarts.

The recorded data is available in the user's fitness history. If you also want to show the data in your app in real time, you need to use the Sensors API together with the Recording API. To record fitness data with session metadata, you can use the Sessions API.

Subscribe to fitness data

To request background collection of sensor data in your app, use the RecordingApi.subscribe method:

If the subscription is added successfully, Google Fit will store fitness data of type TYPE_ACTIVITY_SAMPLE in the fitness history on behalf of your app. This subscription will appear in the list of active subscriptions for your app. To remove this subscription, use the RecordingApi.unsubscribe method.

To subscribe to more types of fitness data in your app, follow the steps in the example above providing a different fitness data type each time.

List active subscriptions

To get a list of the active subscriptions for your app, use the RecordingApi.listSubscriptions method:

Unsubscribe from fitness data

To stop collecting sensor data in your app, use the RecordingApi.unsubscribe method:

Send feedback about...

Google Fit
Google Fit