Preface - The Android Developer’s Cookbook: Building Applications with the Android SDK, Second Edition (2013)

The Android Developer’s Cookbook: Building Applications with the Android SDK, Second Edition (2013)

Preface

Android is the fastest growing mobile operating system (OS). With more than 800,000 applications available in the Google Play store, the Android ecosystem is growing as well. There is enough diversity in device features and wireless carriers to appeal to just about anyone.

Netbooks have always been a natural platform to adopt Android, but the liveliness behind Android has fed the growth further into tablets, televisions, and even automobiles. Many of the world’s largest corporations—from banks to fast food chains to airlines—have established a presence in Android and offer compatible services. Android developers have many opportunities, and relevant apps reach more people than ever before, increasing the satisfaction of creating a relevant app.

Why an Android Cookbook?

The Android OS is simple to learn, and Google provides many libraries to make it easy to implement rich and complex applications. The only aspect lacking, as mentioned by many in the Android developer community, is clear and well-explained documentation. The fact that Android is open source means anyone can dive in and reverse engineer some documentation. Many developer bulletin boards have excellent examples that were deduced using exactly this method. Still, a book that has a consistent treatment across all areas of the OS is useful.

In addition, a clear working example is worth a thousand words of documentation. Developers faced with a problem usually prefer to do a form of extreme programming; that is, they find examples of working code that does something close to the solution and modify or extend it to meet their needs. The examples also serve as a way to see the coding style and help to shape other parts of the developer’s code.

This Android cookbook fills a need by providing a variety of self-contained recipes. As each recipe is introduced, the main concepts of the Android OS are also explained.

Who Should Read This Book?

Users who are writing their own Android applications will get the most out of this cookbook. Basic familiarity with Java and the Eclipse development environment is assumed but not required for the majority of the book. Java is a modular language, and most (if not all) of the example recipes can be incorporated with minimal change into the reader’s own Android project. The motivation and coverage of each topic in this book make it usable as an Android course supplement.

Using the Recipes

In general, the code recipes in this cookbook are self-contained and include all the information necessary to run a working application on an Android device. Chapters 1 and 2 give an introduction to the overall use of Android, but feel free to jump around and start using whatever is necessary.

This book is written first as a reference, providing knowledge mostly by example with the greatest benefits through implementation of the recipes of interest. The main technique introduced in each recipe is specified in the section heading. However, additional techniques are included in each recipe as needed to support the main recipe.

After reading this book, a developer should

Image Be able to write an Android Application from scratch

Image Be able to write code that works across multiple versions of Android

Image Be able to use the various Application Programming Interfaces (APIs) provided in Android

Image Have a large reference of code snippets to quickly assimilate into applications

Image Appreciate the various ways to do the same task in Android and the benefits of each

Image Understand the unique aspects of Android programming techniques

Book Structure

Image Chapter 1, “Overview of Android,” provides an introduction to all aspects of Android outside of the code itself. It is the only chapter that doesn’t include recipes, but it provides useful background material.

Image Chapter 2, “Application Basics: Activities and Intents,” provides an overview of the four Android components and an explanation of how an Android project is organized. It also focuses on the activity as a main application building block.

Image Chapter 3, “Threads, Services, Receivers, and Alerts,” introduces background tasks such as threads, services, and receivers, as well as notification methods for these background tasks using alerts.

Image Chapter 4, “Advanced Threading Techniques,” covers using AsyncTasks and using loaders.

Image Chapter 5, “User Interface Layout,” covers the user interface screen layout and views.

Image Chapter 6, “User Interface Events,” covers user-initiated events such as touch events and gestures.

Image Chapter 7, “Advanced User Interface Techniques,” covers creating a custom view, using animation, offering accessibility options, and working with larger screens.

Image Chapter 8, “Multimedia Techniques,” covers multimedia manipulation and record and playback of audio and video.

Image Chapter 9, “Hardware Interface,” introduces the hardware APIs available on Android devices and how to use them.

Image Chapter 10, “Networking,” discusses interaction outside of the Android device with SMS, web browsing, and social networking.

Image Chapter 11, “Data Storage Methods,” covers various data storage techniques available in Android, including SQLite.

Image Chapter 12, “Location-Based Services,” focuses on accessing the location through various methods such as GPS and using services such as the Google Maps API.

Image Chapter 13, “In-App Billing,” provides an instruction set on including in-app billing in your application using Google Play services.

Image Chapter 14, “Push Messages,” covers how to use GCM for handling push messages with an application.

Image Chapter 15, “Native Android Development,” discusses the components and structure used for native development.

Image Chapter 16, “Debugging,” provides the testing and debugging framework useful throughout the development cycle.

Additional References

There are many online references for Android. A few essential ones are

Image Android Source Code: http://source.android.com/

Image Android Developer Pages: http://developer.android.com/

Image Open Source Directory: http://osdir.com/

Image Stack Overflow Discussion Threads: http://stackoverflow.com/

Image Talk Android Developer Forums: www.talkandroid.com/android-forums/