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

Understanding position-based sensors


The position sensor lets your app determine the position of a device. There are two major sensors in this category: the geomagnetic field sensor and the orientation sensor. The proximity sensor, which measures the proximity of any object to the phone, also comes under this category. The proximity sensor has already been discussed in the previous chapter in detail.

The magnetometer sensor

The magnetometer sensor measures the changes in the earth's magnetic field. It provides the raw magnetic field strength in units of micro tesla (μT). The magnetometer sensor is based on a miniature Hall effect sensor, which detects the earth's magnetic field along the three perpendicular xy, and z axes. The Hall effect sensor measures the magnetic field by generating a voltage that is proportional to the earth's magnetic field strength and polarity. This voltage is converted to micro tesla (μT) values using electric circuits. The magnetometer sensor provides two types...