Getting Started

On a personal note, I'm doing all my development on Mac OS X with Eclipse. All screenshots, IDE information, tips, and tricks will be geared toward the Eclipse IDE. It seems the Android developers had the open source IDE Eclipse in mind, because they've released a plug-in that eases setup and debugging. For the sake of simplicity, I use Eclipse and the Open Handset Alliance's Android. I do not endorse this setup over any other. I will, however, take a little...

Creating the Game Loop

As all game programmers will tell you, most games, at their core, consist of a constant loop. The loop checks for user input and, based on that input and any other game actions, will then draw the new frame frames to the screen. The loop in your sample application will not win any awards for complexity or ingenuity, but it will get your started on your own game-rendering loop. Note If you want to implement your own animation loop outside the view viewGroup hierarchy, look into building a loop...

Installing the Eclipse PlugIn

I like graphical user interfaces (GUIs), provided they have hotkeys like the Eclipse IDE, when working with Android. To get more than basic functionally out of the process, you'll need to download the Android Developer Tools. To install it from within Eclipse, follow the directions outlined by Google at If you've already installed the older version of the SDK and the Eclipse plug-in, I recommend you go back and update it to M5-RC15 (or the latest version) now using the previously mentioned...

Android Essentials

This book covers the essential information required to build an Android application. It will help any developer, amateur, professional, or dabbler who is interested in developing for Android. Over the course of the book, I cover the essentials you'll need to get started with your own innovative application. I took on this project because, after five years of working in the mobile software industry, it has become clear that we need help. With mobile devices becoming more ubiquitous, powerful,...

Getting Under the Hood

You'll now tinker under the hood and kick the tires of Android's widgets. You'll take a basic look at some of the core pieces, many of which you've explored in XML form. As in previous examples, for the sake of explanation, I'll keep it basic. It should be easy to apply what I've discussed here to the more complicated aspects of UI layout. In later, more advanced examples, you'll get more into other Android widgets. In the following example, I've taken pains to make sure you use little to none...

Adding Evil Corporate URLS with a Content Resolver

Maybe they aren't evil, but you'll add them anyway. Since Apress is probably one of the least evil of companies out there not that I'm biased, mind you , you'll let them get away with it, just this once. Here's the fancy ContentReceiver way of adding the bookmark records ContentValues inputValues new ContentValues inputValues.put 1 inputValues.put http www.apress.com inputValues.put Apress, the not so evil company ContentResolver cr getContentResolver inputValues As with most SDKs, there's more...

Getting Splashy

You can download the packaged version of this splash screen example from the downloads section of www.apress.com if you want to use it as a starting point for your own Android application or you want to follow along in a more passive fashion. In this example, because it is your first, I will go through it in a series of small steps. I'll break down exactly what needs to be written, from adding a new image resource to modifying XML layout files. Down the road, examples will not parse out into...

Laying

Most XML screens will be wrapped in a layout object. Layout objects come in many different flavors, each of which you'll look at really quickly and then check out with a simple example in the following sections. Caution At compile time, these XML layout files are parsed and packed by Android into a tight binary format. This saves monstrous amounts of parsing time on startup. However, it means that the XML files cannot be changed by your code during runtime. More specifically, you may be able to...

Scrolling Text Entry Buttons and All the Simple Things in Life

It's now time to put one of the layout classes to use. XML layouts are perfect for user input, information relay, and nearly anything where the contents of the screen are relatively static. You'll add a simple login screen to the aforementioned socially awkward application see Code Listing 3-1 . The first task is to describe what the screen will look like in a new view. You'll use a linear layout so you can just add widgets vertically. Note that this XML requires a general_bg image and the...

Waking Up the Widgets

I've already demonstrated how to use Android's Textview, Button, and EditText widgets. But how useful is a text-entry field if you can't ingest what your users have entered That's a rhetorical question don't answer it I won't be able to hear you I hope . The answer is obvious text entry with no purpose or result is not useful at all. To access the contents of the EditText widgets you defined earlier, you'll have to do two things 1. Get an object handle to the widget you defined in the XML. 2....