Native Libraries

The next layer above the kernel contains the Android native libraries. These shared libraries are all written in C or C++, compiled for the particular hardware architecture used by the phone, and preinstalled by the phone vendor.

Some of the most important native libraries include the following:

• Surface Manager: Android uses a compositing window manager similar to Vista or Compiz, but it's much simpler. Instead of draw

1. http://d.android.com/guide/developing/tools/adb.html

ing directly to the screen buffer, your drawing commands go into off-screen bitmaps that are then combined with other bitmaps to form the display the user sees. This lets the system create all sorts of interesting effects such as see-through windows and fancy transitions.

• 2D and 3D graphics: Two- and three-dimensional elements can be combined 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 back audio in a variety of formats including AAC, AVC (H.264), H.263, MP3, and MPEG-4. 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 iPhone.3 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 library.4 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 higher-level programs. Starting in Android 1.5, 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 online.5

0 0

Post a comment