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

The weather utility app's requirements


Today's Android phones come with environment sensors in them. We will be using the same environment sensors to develop a weather utility app as a part of this chapter. Our app will make use of some additional inputs from external web services combined with our environment sensor's data to drive some more meaningful information, such as dew point, absolute humidity, and altitude. We will also compare weather data obtained from environment sensors to weather data obtained from an external web service. The following are high-level requirements for weather utility apps. The source code of this weather utility app can be found in GitHub under the author's account name and on the support page for the book:

  1. Get the outside temperature using the phone's temperature sensor.
  2. Get the air pressure using the phone's pressure sensor.
  3. Calculate the altitude using the phone's pressure sensor.
  4. Get the relative humidity using the phone's humidity sensor.
  5. Calculate the dew...