Book Image

Getting Started with UDOO

By : Maurizio Caporali, Emanuele Palazzetti
Book Image

Getting Started with UDOO

By: Maurizio Caporali, Emanuele Palazzetti

Overview of this book

Table of Contents (16 chapters)
Getting Started with UDOO
About the Author
About the Reviewers

Improving the prototype

Before we go further with other prototypes, we should think about how we can improve our devices when some unexpected events occur. A good starting point is to think about error handling and, in particular, what happens if the Android application stops hearing incoming data from the accessory. There are many approaches to prevent wrong actions and a good solution is to include a default behavior in the Android application that the prototype should follow in these emergency cases.

We could have used another periodic timer that increases a variable every time it gets executed. When the InputThread instance completes a successful reading, it should reset the above variable. In this way, we can monitor for how much time we stop receiving user inputs and according to this time, we may decide to change the application's behavior. Through this variable, for example, we could stop the radio playback, or turn down the volume a little bit if the accessory stops providing user...