Preface

There was a lot of buzz in late 2007 about a forthcoming Google-backed open source mobile phone venture, but there weren’t a lot of details. We were interested from the outset because we were all involved with open source projects in one way or another, and we were Linux users with a Java background. The new Google-backed “Java/Linux phone platform,” as several blogs and pundits termed it at the time, was exciting and it seemed to suit us perfectly.

Then several official press releases from the Open Handset Alliance came out and the word Java was absent from all of them. At the same time it supposedly ran a “custom virtual machine” and several people who we knew to be Java guys were tapped to work on various parts of it. Was this thing Java or not? This was the first of the ways Android intrigued us, before we were even sure what it was.

When more details about the platform emerged, it became clear that it would use Java “the language” but would avoid the Sun (at the time) virtual machine, and it would deviate from the standard Linux kernel/distribution approach. Google and their OHA partners were using a lot of existing and open tools and components, but were wiring them up in a new way and mixing in parts of their own.

We thought the platform had solid engineering, great timing, and a lot of potential. As soon as the first betas dropped, we grabbed the SDK and tools and started tinkering. We then bought the first Android devices available so we could put the early applications we wrote on our own phones, and we haven’t stopped tinkering since.

We now know Android as a unique platform that’s both open and extremely popular. There isn’t a single device that runs Android anymore; now there are hundreds. And the platform hasn’t been standing still either. There have been many new releases and improvements. Android has grown by leaps and bounds and isn’t showing any signs of slowing down yet.

Still, in all the excitement and growth of Android, one thing has become apparent to us, as developers. It’s extremely easy to start building applications for the platform, because it’s Java-based and familiar to so many, but it’s also easy to get into trouble. Android is a powerful laser gun from the future, but a lot of us still have it aimed at our own feet. Beyond the idiosyncrasies of some of the APIs and the new capabilities such as GPS, cameras, and hardware sensors, there’s also a constrained environment with limited resources. It’s not enough to craft a new UI, get a web service working to talk to the network, and be able to use the GPS, for example. You need to do all that within a lifecycle that restarts your code when the device orientation changes, while supporting different screen sizes, without blocking the UI thread, playing nicely with system resources, and more. It’s easy to create Android applications, but it’s hard to create good Android applications.

This is where Android in Practice came into being. We’ve written Android apps downloaded by millions of users and have learned much along the way. As we learned from both our successes and failures, we published articles and wrote blog posts about Android. We collected a tip or a recipe here and there and tried to share it. We even read a few good introductory Android books, or smaller books that covered several topics well but left other things out. We realized there was a gap. There wasn’t a book that started with the basics and then went into more depth with nontrivial examples and covered everything we thought was important—from background and development to building and testing and more. We got together and shared our ideas and collected our articles and a new book project was born.

What you’re now holding in your hands is our effort at sharing our experiences and knowledge in trying to craft a book that both beginners and advanced users can learn from and use as a reference. We hope you’ll find advice and techniques in this book that are truly useful, and we hope it helps you become aware of how to build great Android applications that are successful on the Android platform for years to come.

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

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