Book Image

Android Things Projects

By : Francesco Azzola
Book Image

Android Things Projects

By: Francesco Azzola

Overview of this book

Android Things makes developing connected embedded devices easy by providing the same Android development tools, best-in-class Android framework, and Google APIs that make developers successful on mobile. With this book, you will be able to take advantage of the new Android framework APIs to securely build projects using low-level components such as sensors, resistors, capacitors, and display controllers. This book will teach you all you need to know about working with Android Things through practical projects based on home automation, robotics, IoT, and so on. We’ll teach you to make the most of the Android Things and build enticing projects such as a smart greenhouse that controls the climate and environment automatically. You’ll also create an alarm system, integrate Android Things with IoT cloud platforms, and more. By the end of this book, you will know everything about Android Things, and you’ll have built some very cool projects using the latest technology that is driving the adoption of IoT. You will also have primed your mindset so that you can use your knowledge for profitable, practical projects.
Table of Contents (15 chapters)
Title Page
About the Author
About the Reviewers
Customer Feedback

How to implement a web interface

There are some devices that do not support the UI or times when we do not want to create an UI and we prefer to expose a web interface instead. This is possible in Android Things by implementing a simple HTTP Web server. In this paragraph, we will describe how to use a web interface to control the RGB LED string in the same way we did previously. The basic idea that stands behind this is creating an HTML page where the user can set the values to control the LED strip. To do it we have to follow these steps:

  1. Create a HTTP server to handle the incoming requests.
  2. Create an HTML page containing all the controls to configure the RGB LED strip.
  3. Embed the HTTP server into the Android Things app.

Let us describe how to do it.

Implementing a simple HTTP web server

The first step is implementing a simple HTTP Web server. To do it we will use an interesting project called NanoHttpd ( This is a light-weight HTTP server designed to be...