Advertisement
  1. Code
  2. Android
Code

Google Fit for Android: An Overview

by
Difficulty:BeginnerLength:QuickLanguages:
This post is part of a series called Google Fit for Android.
Google Fit for Android: Reading Sensor Data

What Is Google Fit?

Google Fit is included in Google Play Services and allows developers to store fitness data for users in order to help users keep track of their exercise habits. All data stored through Google Fit is stored online and is accessible by the user from multiple devices. The user never has to worry about losing their information if they upgrade or change devices.

In this tutorial, I introduce you to Google Fit for Android and you learn what APIs are available for you to use.

Google Fit for Android Users

Getting Started

Before users can use the Google Fit features of your application, you need to register your application through the Google Developers Console. You can then enable the Google Fit API in the developers console and create an OAuth client ID that can be used for your app to access fitness data stored through Google.

Once you have a client ID that can be used in your application, you need to connect a GoogleApiClient in your application and request the necessary features for your application. While registering and connecting your application are beyond the scope of this overview, you can find a detailed walkthrough on the Android developers website. Once your application is set up and the user has granted your application permission to access their information, you are ready to go.

APIs

Google Fit for Android is made up of various APIs that allow developers to perform specific tasks. Before you can dive into each API and use them in your apps, you should have a general idea of what each API does.

Sensors

This API allows you to access the raw information from sensors on the device. Not only can you access standard hardware on a mobile phone, but you can also access sensor data from accessories, such as an Android Wear device.

Recording

The Recording API allows your application to subscribe to specific pieces of data and automatically store them. This lets the user or your application access this information from any device that the user has granted permission to.

History

This API lets you access an archival database. You can perform standard operations, such as inserting, deleting, and querying fitness data that has been previously stored.

Sessions

The Sessions API allows your application to record data over a period of time in order to aggregate information. This can be useful for situations where data without a timeframe or an associated activity isn't as useful as data with a context, such as the user's heart rate during a run.

Bluetooth Low Energy

While the Sensors API allows your application to access sensor data from wearables that support Google Fit, the Bluetooth Low Energy API allows your application direct access to Bluetooth devices in order to store data from them.

Config

While Google Fit provides a large number of data types that can be accessed by an application, there may be times when you, the developer, have access to additional data that doesn't fit into the standard categories. For these situations, you can use the Config API. This allows your application to store and retrieve data of a new type so that it can be accessed through Google Fit with ease.

Conclusion

Google Fit is a powerful and promising platform, for users as well as developers. Even though this tutorial has only given you a brief overview of the Google Fit platform and its capabilities, it should now be clear what the platform has to offer and how you can use it in your own applications. If you'd like to learn more about Google Fit, visit the documentation on Google's developers website.

Advertisement
Advertisement
Looking for something to help kick start your next project?

Envato Market has a range of items for sale to help get you started.