【正文】
mands go into offscreen bitmaps that are then bined with other bitmaps to form the display the user sees. This lets the system create all sorts of interesting effects such as seethrough windows and fancy transitions. ? 2D and 3D graphics: Two and threedimensional elements can be bined in a single user interface with Android. The library will use 3D hardware if the device has it or a fast software renderer if it doesn’t. See Chapter 4, Exploring 2D Graphics, on page 73 and Chapter 10, 3D Graphics in OpenGL, on page 198. ? Media codecs: Android can play video and record and play backaudio in a variety of formats including AAC, AVC (), , MP3, and MPEG4. See Chapter 5, Multimedia, on page 105 for an example. ? SQL database: Android includes the lightweight SQLite database engine,2 the same database used in Firefox and the Apple You can use this for persistent storage in your application. See Chapter 9, Putting SQL to Work, on page 178 for an example. ? Browser engine: For the fast display of HTML content, Android uses the WebKit This is the same engine used in the Google Chrome browser, Apple’s Safari browser, the Apple iPhone, and Nokia’s S60 platform. See Chapter 7, The Connected World, on page 130 for an example. These libraries are not applications that stand by themselves. They exist only to be called by higherlevel programs. Starting in Android , you can write and deploy your own native libraries using the Native Development Toolkit (NDK). Native development is beyond the scope of this book, but if you’re interested, you can read all about it Android Runtime Also sitting on top of the kernel is the Android runtime, including the Dalvik virtual machine and the core Java libraries. The Dalvik VM is Google’s implementation of Java, optimized for mobile devices. All the code you write for Android will be written in Java and run within the VM. Dalvik differs from traditional Java in two important ways: ? The Dalvik VM runs .dex files, which are converted at pile time from standard .class and .jar files. .dex files are more pact and efficient than class files, an important consideration for the limited memory and batterypowered devices that Android targets. 浙江大學城市學院畢業(yè)論文 外文翻譯 24 ? The core Java libraries that e with Android are different from both the Java Standard Edition (Java SE) libraries and the Java Mobile Edition (Java ME) libraries. There is a substantial amount of overlap, however. In Appendix A, on page 278, you’ll find a parison of Android and standard Java libraries. Application Framework Sitting above the native libraries and runtime, you’ll find the Application Framework layer. This layer provides the highlevel building blocks you will use to create your applications. The framework es preinstalled with Android, but you can also extend it with your own ponents as needed. The most important parts of the framework are as follows: ? Activity Manager: This controls the life cycle of applications (see Section , It’s Alive!, on page 35) and maintains a mon“ backstack” for user navigation. ? Content providers: These objects encapsulate data that needs to be shared between applications, such as contacts. See Section , Content Providers, on page 40. ? Resource manager: Resources are anything that goes with your program that is not code. See Section , Using Resources, on page 40. ? Location manager: An Android phone always knows where it is. See Chapter 8, Locating and Sensing, on page 161. ? Notification manager: Events such as arriving messages, appointments, proximity alerts, alien invasions, and more can be presented in an unobtrusive fashion to the user. Applications and Widgets The highest layer in the Android architecture diagram is the Applications and Widgets layer. Think of this as the tip of the Android iceberg. End users will see only these programs, blissfully unaware of all the action going on below the waterline. As an Android developer, however, you know better. Applications are programs that can take over the whole screen and interact with the user. On the other hand, widgets (which are sometimes called gadgets), operate only in a small rectangle of the Home screen application. The majority of this book will cover application development, because that’s what most of you will be writing. Widget development is covered in Chapter 12, There’s No Place Like Home, on page 233. When someone buys an Android phone, it will e prepackaged with a number of 浙江大學城市學院畢業(yè)論文 外文翻譯 25 standard system applications, including the following: ? Phone dialer ? Email ? Contacts ? Web browser ? Android Market Using the Android Market, the user will be able to download new programs to run on their phone. That’s where you e in. By the time you finish this book, you’ll be able to write your own killer applications for Android. Now let’s take a closer look at the life cycle of an Android application. It’s a little different from what you’re used to seeing. It’s Alive! On your standard Linux or Windows desktop, you can have many applications running and visible at once in different windows. One of the windows has keyboard focus, but otherwise all the programs are equal. You can easily switch between them, but it’s your responsibility as the user to move the windows around so you can see what you’re doing and close programs you don’t need. Android doesn’t work that way. In Android, there is one foreground application, which typically takes over the whole display except for the status line. When the user turns on their phone, the first application they see is the Home application (see Figure , on the next page). When the user runs an application, Android starts it and brings it to the foreground. From that applicati