Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Android Sensor Programming By Example

You're reading from  Android Sensor Programming By Example

Product type Book
Published in Apr 2016
Publisher Packt
ISBN-13 9781785285509
Pages 194 pages
Edition 1st Edition
Languages
Author (1):
Varun Nagpal Varun Nagpal
Profile icon Varun Nagpal

Table of Contents (13) Chapters

Android Sensor Programming By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Sensor Fundamentals 2. Playing with Sensors 3. The Environmental Sensors – The Weather Utility App 4. The Light and Proximity Sensors 5. The Motion, Position, and Fingerprint Sensors 6. The Step Counter and Detector Sensors – The Pedometer App 7. The Google Fit Platform and APIs – The Fitness Tracker App

Time for action – adjusting the screen brightness using the light sensor


One of the most common use cases for the light sensor is to adjust the screen brightness according to the external lighting conditions. The maximum range of the light sensor might be different on different Android devices, but most of them support from 0 lux to several thousand lux. Lux is the standard unit for measuring the luminance of the light falling on a surface. For our example, we will use a range from 0 to 100 lux, as normal indoor lighting falls within this range. But for sunlight and strong lights the range can go up to 1,000 lux or more. In the sample app, we will increase the screen brightness, when the indoor lighting goes low, and similarly we will decrease the screen brightness when it goes high.

  1. We followed the standard steps to get values from the sensor. We select the sensor type to the TYPE_LIGHT in the getDefaultSensor() method of SensorManager. We also called the custom initScreenBrightness() method...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime}