Android is everywhere. In mid-2014, Android ran on 62 percent of all smartphones in the United States and on 84 percent of all smartphones worldwide.1 In a study that spans the Americas, Europe, Asia, and the Middle East, Statista reports that Android tablet shipments outnumber iPad shipments by 23 million.2 Over a million apps are available for download at the Google Play Store (more than double the number of apps that were available in June 2012).3 And, in the year between June 2013 and June 2014, Google paid more than $5 billion in revenues to independent developers of Google Play apps.4
So if you read this book in a public place (on a commuter train, at the beach, on the dance floor at the Coyote Ugly saloon), you can read proudly, with a chip on your shoulder and with your chest held high. Android is hot stuff, and you’re cool because you’re reading about it.
You can attack this book in either of two ways. You can go cover to cover, or you can poke around from one chapter to another. You can even do both (start at the beginning and then jump to a section that particularly interests you). I designed this book so that the basic topics come first and the more involved topics follow the basics. But you may already be comfortable with some basics, or you may have specific goals that don’t require you to know about certain topics.
In general, my advice is as follows:
Almost every technical book starts with a little typeface legend, and this book is no exception. What follows is a brief explanation of the typefaces used in this book:
computerese
font. I use computerese for Java code, filenames, web page addresses (URLs), onscreen messages, and other such things. Also, if something you need to type is really long, it appears in computerese font on its own line (or lines).public void
Anyname
italicized computerese
.Pick the first chapter or section that has material you don’t already know and start reading there. Of course, you may hate making decisions as much as I do. If so, here are some guidelines that you can follow:
If you want to skip the sidebars and the Technical Stuff icons, please do. In fact, if you want to skip anything at all, feel free.
In this book, I make a few assumptions about you, the reader. If one of these assumptions is incorrect, you’re probably okay. If all these assumptions are incorrect … well, buy the book anyway.
I assume that you can navigate through your computer’s common menus and dialog boxes. You don’t have to be a Windows, Macintosh, or Linux power user, but you should be able to start a program, find a file, put a file into a certain directory … that sort of thing. Much of the time, when you practice the stuff in this book, you’re typing code on your keyboard, not pointing and clicking your mouse.
On those occasions when you need to drag and drop, cut and paste, or plug and play, I guide you carefully through the steps. But your computer may be configured in any of several billion ways, and my instructions may not quite fit your special situation. So when you reach one of these platform-specific tasks, try following the steps in this book. If the steps don’t quite fit, consult a book with instructions tailored to your system.
I assume that you have some experience with Java. In writing this book, I’ve tried to do the impossible. I’ve tried to make the book interesting for experienced programmers, yet accessible to people who don’t write code for a living. If you’re a Java guru, that’s great. If you’re a certified Linux geek, that’s great, too. But I don’t assume that you can recite the names of the Java’s concurrency methods in your sleep, or that you can pipe together a chain of 14 Linux commands without reading the documentation or touching the Backspace key.
If you have a working knowledge of some Java-like language (C or C++, for example), all you need is a little Java overview. And if you have no experience with an object-oriented language, you can get some. Your favorite bookstore has a terrific book titled Java For Dummies, 6th Edition, by Barry Burd (John Wiley & Sons, Inc.). I recommend that book highly.
This book is divided into subsections, which are grouped into sections, which come together to make chapters, which are lumped finally into six books. (When you write a book, you get to know your book’s structure pretty well. After months of writing, you find yourself dreaming in sections and chapters when you go to bed at night.) Each of the six books is listed here.
This part is your complete, executive briefing on Android application development. It includes some “What is Android?” material, instructions for setting up your system, and a chapter in which you create your first Android app. In this minibook, you visit Android’s major technical ideas and dissect a simple Android application.
When you create Android apps, you write Java programs and work with XML documents. Book II provides a quick look at the Java programming language and at the XML document standard. In addition, Book II has a chapter on Android Studio — a tool that you will be using every minute of your Android-development day.
This minibook covers the big ideas in Android application programming. What is an activity? What is an intent? How do you handle button presses? How do you lay out the user’s screen? The ideas in this minibook permeate all Android programming, from the simplest app on a cheapo phone to a killer app on an overpriced Android tablet.
Some applications do very ordinary things, such as displaying lists or calculating sums. But other apps make use of a mobile device’s unique capabilities. For example, apps can dial phone numbers, send text messages, surf the web, and track your travel direction. The Android platform has a rich set of built-in tools for programming each of these special capabilities. So in this minibook, you create apps that make the most of a device’s vast feature set.
I did a quick count of the most popular apps on the Google Play Store. By far, the apps that people download the most are games. The Games category dominates in both paid installations and overall number of installations. Game development can be tricky because games have lots of moving parts — sprites that jump up and down, collisions between heroes and monsters, playing cards that snap into place, and other crazy things. Chapter 5 in Book IV covers some of these crazy things.
And what happens when you win a game? You share your score on Twitter so that other players are envious! To do this, you need some social networking tools. So Book IV shows you how to connect with social media sites.
Deep in the bowels of a place called “computer nerd city,” some programmers shun the easygoing life of the Android Java programmer and strive toward a simpler, more primitive existence. These “wonks” (as they’re known by clinicians and other professionals) prefer the rugged, macho lifestyle that programming in C or C++ provides. Along with this lifestyle, they get the ability to reach the corners of a mobile device that are hidden by Android’s layer of abstraction. If any of these development alternatives tickle your fancy, please include Book IV, Chapter 6 in your travel plans.
Size matters! The first versions of Android were for smartphones and a typical smartphone has a four- or five-inch screen. (To discover a screen’s size, measure along the diagonal.) Along came tablets, whose screens measure seven or ten inches. Apps that were designed for phones looked really ugly on the larger tablet screens, so later versions of Android had a new fragments feature. (On a tablet screen with sufficient space, a fragment is one of two window-like things. More on that in Chapter 1 of Book V.)
Next came Android Wear (for watches), and Android TV. A watch has a one-inch screen. And, in the parlance of user interface design, television is a “ten-foot experience.” The user sits on a couch and controls the device with a remote control or a game controller.
Each kind of device has its own look and feel and its own app design strategies. So each kind of device has its own flavor of Android. Book V breaks away from Android’s traditional attachment to smartphones, and covers some of the coding that you use in Android’s expanding ecosystem.
Imagine earning a fortune selling the world’s most popular Android app, being named Time magazine’s Person of the Year, and having Tom Cruise or Julia Roberts buy the rights to star as you in a movie (giving you exclusive rights to the game for Android devices that’s based on the movie, of course).
Okay, maybe your ambitions aren’t quite that high, but when you develop a good Android app, you probably want to share that app with the rest of the world. Well, the good news is, sharing is fairly easy. And marketing your app isn’t as difficult as you might imagine. Book VI provides the tips and pointers to help you spread the word about your fantastic application.
You’ve read the Android All-in-One book, seen the Android All-in-One movie, worn the Android All-in-One T-shirt, and eaten the Android All-in-One candy. What more is there to do?
That’s easy. Just visit this book’s website — www.allmycode.com/Android
. (You can also get there by visiting www.dummies.com/go/androidapplicationaio
.) At the website, you can find updates, comments, additional information, and answers to commonly asked readers' questions. You can also find a small chat application for sending me quick questions when I’m online. When I’m not online (or if you have a complicated question), you can send me email. I read messages sent to [email protected]
.
If you could watch me write this book, you’d see me sitting at my computer, talking to myself. I say each sentence in my head. Most of the sentences, I mutter several times. When I have an extra thought, a side comment, or something that doesn’t belong in the regular stream, I twist my head a little bit. That way, whoever’s listening to me (usually, nobody) knows that I’m off on a momentary tangent.
Of course, in print, you can’t see me twisting my head. I need some other way of setting a side thought in a corner by itself. I do it with icons. When you see a Tip icon or a Remember icon, you know that I’m taking a quick detour.
Here’s a list of icons that I use in this book.
Answer: A Remember icon.
I’ve written a lot of extra content that you won’t find in this book. Go online to find the following:
www.dummies.com/cheatsheet/androidappdevelopmentaio
.www.dummies.com/extras/androidappdevelopmentaio
.If you’ve gotten this far, you’re ready to start reading about Android application development. Think of me (the author) as your guide, your host, your personal assistant. I do everything I can to keep things interesting and, most important, help you understand.
Occasionally, we have updates to our technology books. If this book does have technical updates, they will be posted at www.dummies.com/extras/androidappdevelopmentaio
and at http://allmycode.com/android
.
44.220.184.63