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

Sensor availability based on the Android API level


There is a wide variety of sensors that are supported on Android devices. As Android evolved over a period of time, new sensors were added, and some old, inefficient sensors were removed. With the release of newer versions of Android, they got better and more accurate, and the list of supported sensors got bigger. Most of the apps have to support older versions of Android to target the wider audience. But at the same time, not all sensors are supported by older versions of Android. It's a tradeoff between supporting older versions of Android versus getting to use the latest and more advanced sensors that are only available in newer versions of Android.

The following table provides the sensor availability list based on the Android version and API levels. This table illustrates four major platforms to show availability, as the major changes were made in these four platforms only:

Sensor

Android 6.0 (API Level 23)

Android 4.0 (API Level 14)

Android 2.3 (API Level 9)

Android 2.2 (API Level 8)

Accelerometer

Available

Available

Available

Available

Ambient temperature

Available

Available

NA

NA

Gravity

Available

Available

Available

NA

Gyroscope

Available

Available

Available

NA

Light

Available

Available

Available

Available

Linear acceleration

Available

Available

Available

NA

Magnetic field

Available

Available

Available

Available

Orientation

Deprecated

Deprecated

Deprecated

Deprecated

Pressure

Available

Available

Available

NA

Proximity

Available

Available

Available

Available

Relative humidity

Available

Available

NA

NA

Rotation vector

Available

Available

Available

NA

Step Detector

Available

NA

NA

NA

Step Counter

Available

NA

NA

NA

Temperature

Deprecated

Deprecated

Available

Available