[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples/Code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Getting Started on Android
This guide explains how to start developing with Google Fit on Android.
Setup
Before you start building your app, complete these steps.
Get a Google Account
To use the Google Fit APIs, you need a Google Account. You can create a new account or
use an existing account. You may want to create a separate account to test
your app from a user's perspective.
Get Google Play services
Get the latest client library for Google Play services on your development host:
This makes sure that gradle downloads the fitness SDK when building your app automatically.
Build and test your app
Once you've finished the setup steps, you can start building your app. Learn
about the types of data your app can store and
read. Learn more about working with
data in Google Fit.
The data types your app wants access to correspond to authorization scopes. To ask for these permissions, you just need to add which data types your app needs access to in a FitnessOptions instance. When your app asks to use any of the Google Fit data types, the Android SDK automatically checks which scopes they belong to and asks the user for authorization to those scopes.
Create an API client
Create an API client and add the data types your app needs access to, to write and/or read data:
Sensors Client: Access different sources of health and wellness data from hardware sensors in the local device and in companion devices.
Recording Client: For low-power, always-on background collection of sensor data.
History Client: Insert, delete, and read historical data in Google Fit.
This is the resulting authorization flow that users will experience when being
asked for permissions.
See the user authorization flow
Figure 1.The authorization flow for users.
Android permissions: Users see what Android permissions your app has requested before downloading it.
Check and connect: Once downloaded, they grant or deny these permissions. Your app checks if permissions were granted before requesting access to other data types.
OAuth scopes request: Google prompts the user to grant your app the OAuth scopes needed for the data types it wants to access.
Access applied: Your app can access the data types that belong to the scopes the user has granted permission for.