
Android Sensor Programming By Example
Description
Alles über E-Books | Antworten auf Fragen rund um E-Books, Kopierschutz und Dateiformate finden Sie in unserem Info- & Hilfebereich.
Key Features
Get a thorough understanding of the fundamentals and framework of Android sensors.
Acquire knowledge of advance sensor programming, and learn how to connect and use sensors in external devices such as the Android Watch, Polar heart rate monitors, Adidas speed cells, and so on.
Learn from real-world sensor-based applications such as the Pedometer app to detect daily steps, the Driving app to detect driving events, and the Professional Fitness tracker app to track heart rate, weight, daily steps, calories burned, and so on.
Book DescriptionAndroid 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.What you will learn
Learn about sensor fundamentals, different types of sensors, and the sensor co-ordinate system
Understand the various classes, callbacks, and APIs of the Android Sensor framework
Check all the available sensors on an Android device and know their individual capabilities-for example, their range of values, power consumption, and so on.
Implement sensor fusion using two or more sensors together and learn to compensate for the weakness of one sensor by using the strength of another
Build a variety of sensor based, real-world applications such as Weather, Pedometer, Compass, Driving Events Detection, Fitness Tracker, and so on.
Get to know about wake up and non-wake up sensors, wake locks, and how to use sensor batch processing along with the sensor hardware FIFO queue
Develop efficient battery and processor algorithms using raw sensor data to solve real-world problems
Connect to a variety of remote sensors such as body weight measurement and body fat percentage measurement using the Google Fit platform from your Android app
Who this book is forThis book is targeted at Android developers who want to get a good understanding of sensors and write sensor-based applications, or who want to enhance their existing applications with additional sensor functionality. A basic knowledge of Android development is required
All prices
More details
Other editions
Additional editions

Person
Varun Nagpal has been developing mobile apps since 2005 and has developed and contributed to more than 100 professional apps and games on various platforms, such as Android, iOS, Blackberry, and J2ME. Android app development has been his main area of expertise, and he has developed apps for a wide variety of Android devices, such as Android phones, tablets, watches, smart TVs, Android Auto, and Google Glass. He moved to Chicago in late 2013, and since then, he has become a seasoned mobile architect. He has worked in different roles (mobile architect, technical lead, senior developer, and technical consultant) for a variety of various global clients (Allstate, Verizon, AT&T, Sydbank Denmark, SiS Taiwan, Chams PLC Nigeria, and Nandos South Africa) in order to implement their mobile solutions. He has SCJP (Core Java) and SCWD (JSP and Servlets) certifications from Sun Microsystems and MCP (C#) and MCTS (ASP.NET) certifications from Microsoft. You can find his blogs on mobile technology and white papers written by him on his website at http://www.varunnagpal.com/. When he's not working, Varun can be found meditating or playing the flute. He also loves to develop meditation apps and fun games in his free time. He has developed about 40 meditation apps and games available on Google Play (https://play.google.com/store/apps/developer?id=Creative.Software.Studio) and the Apple App Store (https://itunes.apple.com/us/artist/creative-software-studio/id574745824) under the name of Creative Software Studio, his part-time start-up company (http://creativesoftwarestudio.com/).
Content
Sensor Fundamentals
Starting to play with Sensors
Environmental Sensors (Weather Utility App)
Light and Proximity Sensors
Motion, Position and Fingerprint Sensors
Step Counter & Detector Sensors (Pedometer App)
Google Fit Platform and APIs (Fitness Tracker App)
Bonus Chapter: Sensor Fusion and Sensors Based APIs (Driving Events Detection App)
Motion, position, and environmental sensors
The Android platform supports mainly three broad categories of sensors: the motion, position, and environment-based sensors. This categorization is done based on the type of physical quantity detected and measured by the sensors.
Motion sensors
Motion sensors are responsible for measuring any kind of force that could potentially create motion in the x, y, and z axes of the phone. The motion could be either a linear or angular movement in any direction. This category includes accelerometers, gravity, gyroscope, and rotational vector sensors. Most of these sensors will have values in the x, y, and z axes, and the rotational vector will especially have extra value in the fourth axis, which is the scalar component of the rotation vector.
The following table summarizes the motion sensor usage, types, and power consumption:
Sensor
Type
Value
Underlying Sensors
Description
Common Usage
Power Consumption
Accelerometer
Physical
Raw
Accelerometer
This measures the acceleration force along the x, y, and z axes (including gravity). Unit: m/s2
It can be used to detect motion such as shakes, swings, tilt, and physical forces applied on the phone.
Low
Gravity
Synthetic
Fused
Accelerometer, Gyroscope
This measures the force of gravity along the x, y, and z axes. Unit: m/s2
It can be used to detect when the phone is in free fall.
Medium
Linear Acceleration
Synthetic
Fused
Accelerometer, Gyroscope
It measures the acceleration force along the x, y, and z axes (excluding gravity). Unit: m/s2
It can be used to detect motion such as shakes, swings, tilt, and physical forces applied on phone.
Medium
Gyroscope
Physical
Raw, Calibrated
Gyroscope
This measures the rate of rotation of the device along the x, y, and z axes. Unit: rad/s
It can be used to detect rotation motions such as spin, turn, and any angular movement of the phone.
Medium
Step Detector
Synthetic
Calibrated
Accelerometer
This detects walking steps.
It can be used to detect when a user starts walking.
Low
Step Counter
Synthetic
Calibrated
Accelerometer
It measures the number of steps taken by the user since the last reboot while the sensor was activated
It keeps track of the steps taken by the user per day.
Low
Significant Motion
Synthetic
Calibrated
Accelerometer
It detects when there is significant motion on the phone because of walking, running, or driving.
It detects a significant motion event.
Low
Rotation Vector
Synthetic
Fused
Accelerometer, Gyroscope, Magnetometer
This measures the rotation vector component along the x axis (x * sin(?/2)), y axis (y * sin(?/2)), and z axis (z * sin(?/2)). Scalar component of the rotation vector ((cos(?/2)). Unitless.
It can be used in 3D games based on phone direction.
High
Position sensors
Position sensors are used to measure the physical position of the phone in the world's frame of reference. For example, you can use the geomagnetic field sensor in combination with the accelerometer to determine a device's position relative to the magnetic North Pole. You can use the orientation sensor to determine the device's position in your application's frame of reference. Position sensors also support values in the x,y, and z axes.
The following table summarizes the position sensor's usage, types, and power consumption:
Sensor
Type
Value
Underlying Sensors
Description
Common Usage
Power Consumption
Magnetometer
Physical
Raw, Calibrated
Magnetometer
This measures the geomagnetic field strength along the x, y, and z axes. Unit: µT
It can be used to create a compass and calculate true north.
Medium
Orientation (Deprecated)
Synthetic
Fused
Accelerometer, Gyroscope, Magnetometer
This measures the Azimuth (the angle around the z axis), Pitch (the angle around the x axis), and Roll (the angle around the y axis). Unit: Degrees
It can be used to detect the device's position and orientation.
Medium
Proximity
Physical
Raw
Proximity
This measures the distance of an object relative to the view screen of a device. Unit: cm
It can be used to determine whether a handset is being held up to a person's ear.
Low
Game Rotation Vector
Synthetic
Fused
Accelerometer, Gyroscope
This measures the rotation vector component along the x axis (x * sin(?/2)), y axis (y * sin(?/2)), and z axis (z * sin(?/2)). It is the scalar component of the rotation vector (cos(?/2)). Unitless. It is based only on the Gyroscope and Accelerometer and does not use the Magnetometer.
It can be used in 3D games based on phone direction.
Medium
Geomagnetic Rotation Vector
Synthetic
Fused
Accelerometer, Magnetometer
This measures the rotation vector component along the x axis (x * sin(?/2)), y axis (y * sin(?/2)), and z axis (z * sin(?/2)). It is the scalar component of the rotation vector (cos(?/2)). Unit less. * It is based only on the Magnetometer and Accelerometer and does not use the Gyroscope.
It can be used in augmented reality apps, which are based on the phone and compass direction.
Medium
Environmental sensors
Environment sensors are responsible for measuring environmental properties, such as temperature, relative humidity, light, and air pressure near the phone. Unlike motion and position sensors, which give sensor values multi-dimensional arrays, the environment sensors report single sensor values.
The following table summarizes the environment sensor's usage, types, and power consumption:
Sensor
Type
Value
Underlying Sensors
Description
Common Usage
Power Consumption
Ambient...
System requirements
File format: ePUB
Copy protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (not Kindle).
The file format ePub works well for novels and non-fiction books – i.e., „flowing” text without complex layout. On an e-reader or smartphone, line and page breaks automatically adjust to fit the small displays.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our ebook Help page.
File format: PDF
Copy-Protection: Adobe-DRM (Digital Rights Management)
System requirements:
- Computer (Windows; MacOS X; Linux): Install the free reader Adobe Digital Editions prior to download (see eBook Help).
- Tablet/smartphone (Android; iOS): Install the free app Adobe Digital Editions or the app PocketBook before downloading (see eBook Help).
- E-reader: Bookeen, Kobo, Pocketbook, Sony, Tolino and many more (only limited: Kindle).
The file format PDF always displays a book page identically on any hardware. This makes PDF suitable for complex layouts such as those used in textbooks and reference books (images, tables, columns, footnotes). Unfortunately, on the small screens of e-readers or smartphones, PDFs are rather annoying, requiring too much scrolling.
This eBook uses Adobe-DRM, a „hard” copy protection. If the necessary requirements are not met, unfortunately you will not be able to open the eBook. You will therefore need to prepare your reading hardware before downloading.
Please note: We strongly recommend that you authorise using your personal Adobe ID after installation of any reading software.
For more information, see our eBook Help page.