get started with google fit and its api

20
T9 Track Session 4/21/2016 2:00 PM "Get Started with Google Fit and Its API" Presented by: Luke Wallace Bottle Rocket Brought to you by: 340 Corporate Way, Suite 300, Orange Park, FL 32073 888-268-8770 · 904-278-0524 · [email protected] · www.techwell.com

Upload: josiah-renaudin

Post on 16-Apr-2017

321 views

Category:

Software


3 download

TRANSCRIPT

Page 1: Get Started with Google Fit and Its API

T9TrackSession4/21/20162:00PM

"GetStartedwithGoogleFitandItsAPI"

Presented by:

Luke Wallace

Bottle Rocket

Broughttoyouby:

340CorporateWay,Suite300,OrangePark,FL32073888-268-8770·904-278-0524·[email protected]·www.techwell.com

Page 2: Get Started with Google Fit and Its API

Luke Wallace Bottle Rocket

Luke Wallace is Bottle Rocket's manager of custom development for all things Android. Luke has successfully led his team to develop Android apps for clients such as Chick-fil-A and Starwood Hotels, managing the process from development to implementing strategic objectives that are aligned with the Android engineering discipline's strategic initiatives. A strong proponent of the Android platform, Luke is an invaluable resource at Bottle Rocket, always bringing the latest perspectives on Android news and updates from within the industry.

Page 3: Get Started with Google Fit and Its API

D E V E L O P I N G A P P S W I T H T H E G O O G L E F I T S D K

B O T T L E R O C K E T P R E S E N T S

[email protected] - @lukeluca

G O O G L E F I T

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

Page 4: Get Started with Google Fit and Its API

G O O G L E F I T

• Any Data

• Any App

• In the Cloud

I N T E R FA C E E X A M P L E S

Web Android

Page 5: Get Started with Google Fit and Its API

C O M P O N E N T S

• Fitness Store

• A central repository that stores data from a variety of devices and apps. The fitness store is a cloud service that is transparent to clients.

• The sensor framework

• A set of high-level representations that make it easy to work with the fitness store. You use these representations with the Google Fit APIs.

M O R E C O M P O N E N T S

• Permissions and user controls

• A set of authorization scopes to request user permission to work with fitness data. Google Fit requires user consent to access fitness data.

• Google Fit APIs

• Android and REST APIs to access the fitness store. You can create apps that support Google Fit on multiple platforms and devices, such as Android, iOS, and Web apps.

Page 6: Get Started with Google Fit and Its API

G O O G L E F I T A R C H I T E C T U R E

P E R M I S S I O N S A N D U S E R C O N T R O L S

Fit requires user consent before apps can read or store fitness data.

Fit defines OAuth scopes in three permission groups with separate read/write privileges

Activity

Location

Body

Each permission group grants apps access to a set of data types.

Apps specify one or more of these scopes to work with fitness data, and Google Fit requests the corresponding permissions from the user.

Page 7: Get Started with Google Fit and Its API

P E R M I S S I O N R E Q U E S T

• Data Sources represent sensors and consist of

• Name

• Type of data collected

• Other sensor details

• A data source may represent a hardware sensor or a software sensor. You can define software sensors in your apps.

• Data Types represent different kinds of fitness data

• Step count

• Heart rate

• Other data types

• Data types establish a schema through which different apps can understand each other's data.

• A data type consists of a name and an ordered list of fields, where each field represents a dimension.

• For example, a data type for location contains three fields (latitude, longitude, and accuracy), whereas a data type for weight contains only one field.

S E N S O R F R A M E W O R K

Page 8: Get Started with Google Fit and Its API

Data Points

• Timestamped array of values for a data type, read from a data source.

• You use data points to record and insert fitness data in the fitness store, and to read raw data from a data source. Points that contain a start time represent a time range instead of an instantaneous reading.

Datasets

• Represent a set of data points of the same type from a particular data source covering some time interval.

• You use datasets to insert data into the fitness store. Queries to read data from the fitness store also return datasets.

Sessions

• Represent a time interval during which users perform a fitness activity, such as a run, a bike ride, or surf session.

• Sessions help organize data and perform detailed or aggregate queries on the fitness store for a fitness activity.

S E N S O R F R A M E W O R K

Graph Example

G R A P H E X A M P L E

Page 9: Get Started with Google Fit and Its API

Users.dataSources

• POST /userId/dataSources

• GET /userId/dataSources

• GET /userId/dataSources/dataSourceId

• PUT /userId/dataSources/dataSourceId

R E S T A P I S

Users.dataSources.datasets

• DELETE /userId/dataSources/dataSourceId/datasets/datasetId

• GET /userId/dataSources/dataSourceId/datasets/datasetId

• PATCH /userId/dataSources/dataSourceId/datasets/datasetId

M O R E R E S T A P I S

Page 10: Get Started with Google Fit and Its API

Users.sessions

• GET /userId/sessions

• PUT /userId/sessions/sessionId

• DELETE /userId/sessions/sessionId

E V E N M O R E R E S T A P I S

• The Google Fit APIs are part of Google Play services.

• The Google Fit APIs are in these packages:

• com.google.android.gms.fitness

• com.google.android.gms.fitness.data

• com.google.android.gms.fitness.request

• com.google.android.gms.fitness.result

• com.google.android.gms.fitness.service

A N D R O I D A P I S

Page 11: Get Started with Google Fit and Its API

U S E T H E N E W A C T I V I T Y W I Z A R D

A R E M I N D E R O N G O O G L E P L AY S E R V I C E S

Page 12: Get Started with Google Fit and Its API

A R E M I N D E R O N G O O G L E P L AY S E R V I C E S

A R E M I N D E R O N G O O G L E P L AY S E R V I C E S

Page 13: Get Started with Google Fit and Its API

C O N N E C T I N G P L AY S E R V I C E S

H A N D L I N G C O N N E C T I O N C A L L B A C K S

Page 14: Get Started with Google Fit and Its API

H A N D L I N G O A U T H C O M P L E T I O N

B U I L D I N G T H E F I T N E S S C L I E N T

Page 15: Get Started with Google Fit and Its API

B U I L D I N G T H E F I T N E S S C L I E N T

Not Automatic!

Saving Your Data

S AV I N G Y O U R D ATA

Page 16: Get Started with Google Fit and Its API

C A L L I N G T H E S E S S I O N A P I

C A L L I N G T H E S E S S I O N A P I

Page 17: Get Started with Google Fit and Its API

C A L L I N G T H E S E S S I O N A P I

S I M P L E U I E N T R Y

Page 18: Get Started with Google Fit and Its API

R E S U LT S V I S I B L E I N G O O G L E F I T

The Android APIs offer much more than we have time for:

BleApi - API for scanning, claiming, and using Bluetooth Low Energy devices.

ConfigApi - API for accessing custom data types and settings.

HistoryApi - API for inserting, deleting, and reading data.

RecordingApi - API for low-power, always-on background collection of sensor data.

SensorsApi - API for fitness data in local/connected devices. Delivers live events to listeners.

A N D S O M U C H M O R E …

Page 19: Get Started with Google Fit and Its API

As a developer of fitness and wellness apps, you often collect and manage important user information. Keep these key principles in mind:

• Always clearly explain to the user what data you will collect and why.

• Honor user requests to delete their data.

• If you read fitness data from Google Fit, you must also write the fitness data you collect to Google Fit.

• Do not use Google Fit APIs for non-fitness purposes, such as storing medical or biometric data, selling data, or using data for advertising.

• Carefully review the Google Fit Terms and Conditions before using Google Fit.

• By using the API, you agree to the Google Fit Terms and Conditions.

R E S P O N S I B L E U S E O F G O O G L E F I T

Google Fit REST API: https://developers.google.com/fit/rest/

Google Fit Android API: https://developers.google.com/fit/android/

Google Fit Developers Challenge: https://developers.google.com/fit/challenge/

Google Fit Web UI: https://fit.google.com

Google Fit Android App: https://play.google.com/store/apps/details?id=com.google.android.apps.fitness&hl=en

Google Fit Terms and Conditions: https://developers.google.com/fit/terms

Gist of code shown in slides:https://gist.github.com/Splaktar/8c955d31bc5db42e64fe

R E F E R E N C E S

Page 20: Get Started with Google Fit and Its API

https://github.com/Lukeluca/GDG-Dallas-Google-Fit-Demo

Now go build something amazing.

[email protected] - @lukeluca