Logo Icon Logo
A Crowd-sourced Cookbook on Writing Great Android® Apps
GitHub logo Twitter logo OReilly Book Cover Art

Preface

Published? true
FormatLanguage: WikiFormat

Problem:

N/A

Discussion:

Android is "the open source revolution" applied to cellular telephony. At least, part of it. There are many other attempts to provide open source cell phones, ranging from the mostly-defunct Openmoko Freerunner through QT Embedded, Moblin, LiMo, Debian Mobile, Maemo to the open-source Symbian OS. Not to mention the established non-open-source stalwart: Apple's iPhone (which has developer toolkits, but the OS is not available as open source).

"Nobody's armchair is a good predictor of the future", though, as Mike O'Dell once said. Other mobile platforms have had their day in the sun and seen the sunset - think about BlackBerry/RIM, and Microsoft Windows Mobile, for example

This book is here to help the Android developer community share the knowledge that will make it happen. Those who contribute knowledge here are helping make Android development easier for those who come after.

Contents


About Android

Android is a mobile technology platform that provides cell phones and other hand-held and mobile devices (even netbooks) with the power and portability of the Linux operating system and the reliability and portability of a standard high-level language and API. Android apps are written in the Java language, using tools such as Eclipse, compiled against the Android API, and translated into bytecode for the Dalvik VM.

Android is thus related by OS family to Openmoko, QT Embedded, MeeGo (the 2010 merger of Nokia's Maemo and Intel's MobLin), OPhone, LiMo and other Linux-based cell phone projects. Android is also related by programming language to Blackberry and JavaME phones, and to Java and the wider realm of Java Enterprise applications.

Who This Book Is For

We assume you know the basics of the Java language. If not, see Learning Java. We also assume you know the basics of the Java Standard Edition API (since this forms the basis of Android's runtime libraries) as well as the basics of Android. The terms "activity", "intent", and "content provider", while not necessarily being what you dream about at night, should at least be familiar to you.

What's in this Book?

Chapter 1, Getting Started, takes you through the steps of setting up the Android development environment and building several simple applications of the well-known "Hello World" type pioneered by Brian Kernighan.

Chapter 2, Designing a successful Application, covers some of the differences in mobile computing that will hit developers coming from desktop and enterprise software environments, and talks about how mobile design (in particular Android design) differs from those other environments.

Testing is often an afterthought for some developers, so we put this early on, in Chapter 3, Testing. Not so you'll skip it, but so you'll read and heed. We talk about unit testing individual components as well as testing out your entire application in a well-controlled way.

In Chapter 4, Content Providers, we show you how to make an application that can be used by other applications through something as simple but ubiquitous (in Android) as the URL.

Every mobile app needs a GUI, so Chapter 5, Graphical User Interface, covers all the ins and outs of GUI development for Android. Examples are given both in XML and in hard-coded GUI development.

Chapter 6, Graphics, covers a range of topics related to graphics, including use of the graphical drawing and compositing facilities in Android as well as using desktop tools to develop graphical images, textures, icons, and so on that will be incorporated into your finished application.

Android is rich in multimedia capabilities. Chapter 7, Multimedia, shows how.

Chapter 8, Data Persistence shows how to save data into files, databases and so on. And how to retreive it later, of course.

Android started out as an operating system for mobile telephones. Chapter 9, Telephone Applications, shows how to control and react to the telephone device that is in most mobile devices nowadays.

Mobile devices are, for the most part, always-on and always-connected. This has a major impact on how people use them and think about them. Chapter 10, Networked Applications, shows the coding for traditional networked applications, and Chapter 11, Cloud Computing, considers massively-distributed applications.

The now-ubiquitous Global Positioning System has also had major implications on how mobile applications work. Chapter 12, Location and Map Applications, discusses how to find your location, how to get map data from Google and OpenStreetMap, and how applications can be location-aware in ways that are just now being explored.

Chapter 13, Accelerometer, talks about the sensors built into most Android devices and how to use them.

There may be a Chapter 14, Bluetooth, if there's enough to say about it, going way beyond connecting your Bluetooth(TM) headset to your phone.

In Chapter 15, Other Programming Languages, we explore the use of other programming languages to write all or part of your Android application. Examples include C, Perl, Python, Lisp, and other languages.

While this book is in English, and English remains the #1 language worldwide, it is far from the only one. And most end users would much rather have an application that has its text in their language and its icons in a form that is culturally correct for them. Chapter 16, Internationalization, goes over the issues of language and culture and how it relates to Android.

Most Android developers hope that their applications will be used by other people. But this won't happen unless users can find your application. Chapter 17, Packaging, deploying and selling, shows how to prepare your application for distribution via the Android Market, and to use that as well as other markets to get your application out to the people that will use it.

Other Books

Java Books

T.B.A.

Android Books

T.B.A.

Programming and Design Books

T.B.A.

Conventions Used in This Book

This book uses the following conventions.

Programming Conventions

The examples shown are in two varieties. Those that begin with zero or more import statements, a Javadoc comment, and a public class statement are complete examples. Those that begin with a declaration or executable statement, of course, are excerpts. However, the full versions of these excerpts have been compiled and run, and the online source for that recipe should include the full versions.

Typesetting Conventions

The following typographic conventions are used in this book:

Italic Used for commands, filenames, and example URLs. It is also used to define new terms when they first appear in the text.

Constant width Used in code examples to show partial or complete Java source code program listings. It is also used for class names, method names, variable names, and other fragments of Java code.

Constant width bold Used for user input, such as commands that you type on the command line.

This icon signifies a tip, suggestion, or general note.

This icon indicates a warning or caution.

Comments and Questions

As mentioned earlier, we rely on each contributor to test all the code on at least one of the Android versions, and hopefully on several. Still, there may be hidden dependencies, or even bugs, in the code. Please report any errors you find, as well as your suggestions for future editions. If you have (or create) an account on the online site, you can attach the comment directly to the Recipe, using the Add Comment feature. You can also reach us by writing to:

O'Reilly Media, Inc. 1005 Gravenstein Highway North Sebastopol, CA 95472 (800) 998-9938 (in the United States or Canada) (707) 829-0515 (international or local) (707) 829-0104 (fax) To ask technical questions or comment on the book, send email to: bookquestions@oreilly.com.

The online website for the book will remain available at https://androidcookbook.com/. We hope it will grow and grow as developers continue to add recipes beyond those in the printed edition of the book.

Getting the Source Code

Unlike most O'Reilly books, there is no 100% central repository of source code. Each developer can choose to make source available electronically, or not. However, the majority of the code examples are online at https://github.com/IanDarwin/Android-Cookbook-Examples/.

Acknowledgments

Thanks to everyone who contributed a recipe or even a comment; extra thanks to those who gave so generously that they made the "top contributors" list!