วันอังคารที่ 29 พฤษภาคม พ.ศ. 2555

Android Beginner


Android Beginner

Google, seeing a large growth of Internet use and search in mobile devices, acquired Android, Inc., in 2005 to focus its development on a mobile device platform.Apple introduced the iPhone in 2007 with some ground breaking ideas including multitouch and an open market for applications.Android was quickly adapted to include these features and to offer definite distinctions, such as more control for developers and multitasking. In addition,Android incorporates enterprise requirements, such as exchange support, remote wipe, and Virtual Private Network (VPN) support, to go after the enterprise market that Research In Motion has developed and held so well with its Blackberry models.
Device diversity and quick adaptation have helped Android grow its user base, but it comes with potential challenges for developers.Applications need to support multiple screen sizes, resolution ratios, keyboards, hardware sensors, OS versions, wireless data rates, and system configurations. Each can lead to different and unpredictable behavior, but testing applications across all environments is an impossible task.
Android has therefore been constructed to ensure as uniform an experience across platforms as possible. By abstracting the hardware differences,Android OS tries to insulate applications from device-specific modifications while providing the flexibility to tune aspects as needed. Future-proofing of applications to the introduction of new hardware platforms and OS updates is also a consideration.This mostly works as long as the developer is well aware of this systematic approach.The generic Application Programming Interfaces (API) that Android offers and how to ensure device and OS compatibility are main threads discussed throughout this book.
Still, as with any embedded platform, extensive testing of applications is required. Google provides assistance to third-party developers in many forms as Android Development Tool (ADT) plugins for Eclipse (also as standalone tools) including real-time logging capabilities, a realistic emulator that runs native ARM code, and in-field error reports from users to developers of Android Market applications.


The Dichotomy of Android
 
Android has some interesting dichotomies. Knowing about them upfront is useful not only in understanding what Android is, but what it is not.
Android is an embedded OS that relies on the Linux kernel for core system services, but it is not embedded Linux. For example, standard Linux utilities such as X-windows and GNU C libraries are not supported.Writing applications for Android utilizes the Java framework, but it is not Java. Standard Java libraries such as Swing are not supported. Other libraries such as Timer are not preferred; they have been replaced by Android’s own libraries, which are optimized for usage in a resource-constrained, embedded environment.
The Android OS is open source, which means developers can view and use any of the system source code, including the radio stack.This source code is one of the first resources for seeing examples of Android code in action, and it helps clarify the usage when documentation is lacking.This also means developers can utilize the system in the same way as any core application and can swap out system components for their own components. However,Android devices do contain some proprietary software that is inaccessible to developers (such as Global Positioning System (GPS) navigation). A final dichotomy of Android OS is that Google is also backing Chrome OS.Android OS is built for embedded platforms, and Chrome OS is built for cloud-based platforms.
However, which is the best choice for embedded devices that live in the cloud? Netbooks, which fill the gap between smart phones and laptop computers, could presumably go either way (and they have).Android has started to utilize the cloud more. Does that mean Chrome OS’s days are numbered? Google also backs a web-based market, so Chrome OS enjoys the same developer leverage that Android currently has.This points to a convergence that might have been in the cards all along.




Devices Running Android
 
There are more than 40 Android phones in the market from more than ten manufacturers.
Other hardware also runs Android, such as tablets and televisions. Software can access information on the target device using the android.os.Build class, for example: if(android.os.Build.MODEL.equals("Nexus+One")) { ... }


Android-supported hardware shares some common features due to the nature of the operating system.The Android OS is organized into the following images:
  • Bootloader—Initiates loading of the boot image during startup
  • Boot image—Kernel and RAMdisk
  • System image—Android operating system platform and apps
  • Data image—User data saved across power cycles
  • Recovery image—Files used for rebuilding or updating the system
  • Radio image—Files of the radio stack
These images are stored on nonvolatile flash memory, so they are protected when the device powers down.The flash memory is used like read-only memory (hence, some call it ROM), but can it be rewritten as necessary (for example, with over-the-air Android operating system updates).
On startup, the microprocessor executes the bootloader to load the kernel and RAMdisk to RAM for quick access.The microprocessor then executes instructions and pages portions of the system and data images into RAM as needed.The radio image resides on the baseband processor, which connects to the radio hardware.
A comparison of some of the early and more recent smart phone models is shown in Table 1.1. It shows that the processing hardware architecture is similar across devices: a microprocessor unit (MPU), synchronous dynamic random access memory (SDRAM or RAM for short), and flash memory (called ROM for short).The screen size is given in pixels, but the dots per inch (dpi) vary depending on the physical screen size. For example, the HTC Magic has a 3.2-inch diagonal screen with 320x480 pixels.This equates to 180 pixels per inch, but is classified as a medium pixel density device by Android (which averages as 160 dpi).All smartphones also offer a CMOS image sensor camera, Bluetooth (BT), and Wi-Fi (802.11), although there are variations.