Book Image

Android Sensor Programming By Example

By : Varun Nagpal
Book Image

Android Sensor Programming By Example

By: Varun Nagpal

Overview of this book

Android phones available in today’s market have a wide variety of powerful and highly precise sensors. Interesting applications can be built with them such as a local weather app using weather sensors, analyzing risky driving behavior using motion sensors, a fitness tracker using step-counter sensors, and so on. Sensors in external devices such as Android Watch, Body Analyzer & Weight Machine, Running Speed Cell, and so on can also be connected and used from your Android app running on your phone. Moving further, this book will provide the skills required to use sensors in your Android applications. It will walk you through all the fundamentals of sensors and will provide a thorough understanding of the Android Sensor Framework. You will also get to learn how to write code for the supportive infrastructure such as background services, scheduled and long running background threads, and databases for saving sensor data. Additionally, you will learn how to connect and use sensors in external devices from your Android app using the Google Fit platform. By the end of the book, you will be well versed in the use of Android sensors and programming to build interactive applications.
Table of Contents (13 chapters)
Android Sensor Programming By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface

Platform basics


The following section explains the platform basics and fitness data formats and terminologies used by the Google Fit platform.

Data sources

Data sources represent unique sources of sensor data. They can expose raw data coming from hardware sensors on local or companion devices, which is categorized as TYPE_RAW. Data sources also expose derived data, created by transforming or merging other data sources, which are categorized as TYPE_DERIVED. They hold the metadata regarding the source, such as which hardware device (device name) or application (package name) generated the data. Multiple data sources can exist for the same data type, for example for the heart rate data type, we can have a heart rate sensor in a watch and a heart rate sensor in a chest wrap that show as two different data sources for one data type.

Data types

A data type defines the representation and format of any fitness data. It consists of a name and an ordered list of fields, where each field represents a...