摘要:
2Getting StartedWHAT'S IN THIS CHAPTER?➤ How to install the Android SDK, create a development environment,and debug your projects.➤ Understanding mobile design considerations and the importance ofoptimizing for speed and efficiency and designing for small screensand mobile data connections.➤ Using Android Virtual Devices, the emulator, and developer tools.All you need to start writing your own Android applications is a copy of the Android SDK andthe Java development kit. Unless you're a masochist, you'll probably want a Java IDE — Eclipseis particularly well supported — to make development a little easier.Versions of the SDK, Java, and Eclipse are available for Windows, MacOS, and Linux, so youcan explore Android from the comfort of whatever OS you favor. The SDK tools and emula-tor work on all three OS environments, and because Android applications are run on a virtualmachine, there's no advantage to developing from any particular operating system.Android code is written with Java syntax, and the core Android libraries include most of thefeatures from the core Java APIs. Before they can be run, though, your projects must first betranslated into Dalvik byte code. As a result, you get the benefits of using Java while your appli-cations have the advantage of running on a virtual machine optimized for mobile devices.The SDK download includes all the Android libraries, full documentation, and excellent sam-ple applications. It also includes tools to help you write and debug your applications, like theAndroid Emulator to run your projects and the Dalvik Debug Monitoring Service (DDMS) tohelp debug them.By the end of this chapter you'll have downloaded the Android SDK, set up your developmentenvironment, completed two new applications, and run and debugged them with the DDMSusing the emulator running on an Android Virtual Device.If you've developed for mobile devices before, you already know that their small-form factor, limitedpower, and restricted memory create some unique design challenges. Even if you're new to the game,18❘CHAPTER 2 GETTING STARTEDit's obvious that some of the things you can take for granted on the desktop or the Web aren't going towork on a mobile.As well as the hardware limitations, the user environment brings its own challenges. Mobile devices areused on the move and are often a distraction rather than the focus of attention, so your applicationsneed to be fast, responsive, and easy to learn and use.This chapter examines some of the best practices for writing mobile applications to help overcome theinherent hardware and environmental challenges. Rather than try to tackle the whole topic, we'll focuson using the Android SDK in a way that's consistent with good mobile design principles.DEVELOPING FOR ANDROIDThe Android SDK includes all the tools and APIs you need to write compelling and powerful mobileapplications. The biggest challenge with Android, as with any new development toolkit, is learning thefeatures and limitations of its APIs.If you have experience in Java development you'll find that the techniques, syntax, and grammar you'vebeen using will translate directly into Android, although some of the specific optimization techniquesmay seem counterintuitive.If you don't have experience with Java but have used other object-oriented languages (such as C#), youshould find the transition straightforward. The power of Android comes from its APIs, not from Java,so being unfamiliar with all the Java-specific classes won't be a big disadvantage.What You Need to BeginBecause Android applications run within the Dalvik virtual machine, you can write them on any plat-form that supports the developer tools. This currently includes the following:➤ Microsoft Windows (XP or later)➤ Mac OS X 10.4.8 or later (Intel chips only)➤ LinuxTo get started, you'll need to download and install the following:➤ The Android SDK➤ Java Development Kit (JDK) 5 or 6You can download the latest JDK from Sun athttp://java.sun.com/javase/downloads/index.jspIf you already have a JDK installed, make sure that it meets the version requirementslist
展开