About Google Fit
“Google Fit is an open ecosystem that allows developers to upload fitness data to a central repository where users can access their data from different devices and apps in one location “. That means you can use your apps (not only Google Fit) or devices such as Apple Watch to upload your fitness data to the Google Fitness Store. You can also get your fitness data that you uploaded from the Store so you can do something else when you need it.
What we always use are SensorsApi, RecordingApi and HistoryApi.
I did a sample project of getting fitness data from Google Fit, and show it in a line chart. As following, I get steps and weight in seven days from today. And these data were almost uploaded by Google Fit app, also I try to use my own app to upload steps data in sensor.
First, of course, you need a Google Account. Google Fit is available on Android devices with Google Play services 7.0 or higher. You should install the Google Play Service in your device, and then install the latest client library for Google Play services on your development host. Finally, get an OAuth 2.0 client ID for your Android applications.
How to begin with code
1.configure your project
Learn about key Google Cloud Platform features and how GCP can help your enterprise by lowering infrastructure cost, driving business efficiencies, and empowering innovation.
if you want to use your own app to upload fitness data, you need to open your location service for sensor to collect data.
5.Create a GoogleApiClient
This client is used to subscribe steps data to Google Fit Store.
You can change the Api and Scope attributes to do different things. For example, to get your weight data from the Store:
Then you can get your fitness data from the DataReadResult. If you want to show it in charts, you can get a third-party library to help you.
It’s not difficult to build a sample project if you refer to official documents, but we need to try harder to better understand it.
That’s all, hope you can give me your advice.