Introduction

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.

How to Use This Book

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:

  • If you already know something, don’t bother reading about it.
  • If you’re curious, don’t be afraid to skip ahead. You can always sneak a peek at an earlier chapter if you really need to do so.

Conventions Used in This Book

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:

  • New terms are set in italics.
  • If you need to type something that’s mixed in with the regular text, the characters you type appear in bold. For example: “Type MyNewProject in the text field.”
  • You also see this 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).
  • You need to change certain things when you type them on your own computer keyboard. For instance, I may ask you to type

    public void Anyname

    which means that you type public void and then some name that you make up on your own. Words that you need to replace with your own words are set in italicized computerese .

What You Don’t Have to Read

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’ve already created a simple Android application, and you have all the right software installed on your computer, skip Book I and go straight to Book II. Believe me, I won’t mind.
  • If you have a modest amount of experience developing Android apps, and you’re looking for material that puts things together and fills in gaps, start with Book II.
  • If you’re thinking about writing a special kind of app (a text-messaging app, a location-based app, a game, or something like that), work your way quickly and impatiently through Books I, II, and III, and dive in seriously when you reach Books IV and V.
  • If your goal is to publish (and maybe sell) your apps, set Book VI as your ultimate goal. No one can tell you how to create the next great game sensation, but Book VI gets you thinking about the best ways to share your Android applications.

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.

Foolish Assumptions

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 can think logically. That’s all there is to application development — thinking logically. If you can think logically, you have it made. If you don’t believe that you can think logically, read on. You may be pleasantly surprised.
  • 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.

How This Book Is Organized

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.

Book I: Getting Started with Android Application Development

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.

Book II: Android Background Material

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.

Book III: The Building Blocks

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.

Book IV: Programming Cool Phone Features

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.

Book V: Apps for Tablets, Watches, and TV Sets

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.

Book VI: The Job Isn’t Done Until …

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.

More on the Web!

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].

Icons Used in This Book

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.

tip A Tip is an extra piece of information — something helpful that the other books may forget to tell you.

warning Everyone makes mistakes. Heaven knows that I’ve made a few in my time. Anyway, when I think people are especially prone to make a mistake, I mark it with a Warning icon.

remember Question: What’s stronger than a Tip, but not as strong as a Warning?

Answer: A Remember icon.

crossreference “If you don’t remember what such-and-such means, see blah-blah-blah,” or “For more information, read blahbity-blah-blah.

ontheweb This icon calls attention to useful material that you can find online. (You don’t have to wait long to see one of these icons. I use one at the end of this introduction!)

technicalstuff Occasionally, I run across a technical tidbit. The tidbit may help you understand what the people behind the scenes (the people who developed Java) were thinking. You don’t have to read it, but you may find it useful. You may also find the tidbit helpful if you plan to read other (more geeky) books about Android app development.

Beyond the Book

I’ve written a lot of extra content that you won’t find in this book. Go online to find the following:

Where to Go from Here

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.

ontheweb If you like what you read, send me an email, post on my Facebook wall, or tweet me a tweet. My email address, which I created just for comments and questions about this book, is [email protected]. My Facebook page is /allmycode, and my Twitter handle is @allmycode. And don’t forget — to get the latest information, visit one of this book’s support websites. Mine is at http://allmycode.com/android , or you can visit www.dummies.com/go/beginningprogrammingwithjavafd.

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.

Notes

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
44.220.184.63