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

Android Devices





 

 Android Devices

Hardware Differences on Android Devices
The hardware available on each Android device varies, as seen in Table 1.1. In general, most of the differences are transparent to the developer and not covered further here. However, a few hardware differences are important to understand to assist in writing device-independent code. Screens, user input methods, and sensors are discussed here.

Screens
Two technologies used for displays are liquid crystal displays (LCD) and light-emitting diodes (LED).The two specific choices in Android phones are thin-film transistor (TFT) LCDs and active-matrix organic LED displays (AMOLED).A benefit of TFT displays is a longer lifetime. A benefit of AMOLED displays is no need for backlighting and therefore deeper blacks and lower power.
Overall,Android devices are categorized into small, normal, and large screens and low-, medium-, and high pixel density. Note that the actual pixel density might vary but will be chosen as one of these.A summary of currently available device screens is shown in Table.

Summary of Device Screens Supported by Android

Screen
Type

Low-Density
(~120ppi), ldpi

Medium-Density
(~160ppi), mdpi

High-Density
(~240ppi), hdpi

Small
screen

QVGA (240x320), 2.6-inch
to 3.0-inch diagonal



Normal
screen

WQVGA (240x400),
3.2-inch to 3.5-inch
diagonal

FWQVGA (240x432), 3.5-
inch to 3.8-inch diagonal

HVGA (320x480), 3.0-
inch to 3.5-inch
diagonal

WVGA (480x800),
3.3-inch to 4.0-inch
diagonal

FWVGA (480x854),
3.5-inch to 4.0-inch
diagonal

Large
screen


WVGA (480x800),
4.8-inch to 5.5-inch
diagonal

FWVGA (480x854),
5.0-inch to 5.8-inch
Diagonal


           

User Input Methods
Touchscreens enable users to interact with the visual display.There are three types of touchscreen technology:
  • Resistive—Two resistive material layers sit on top of a glass screen.When a finger, stylus, or any object applies pressure, the two layers touch together and the location of the touch can be determined. Resistive touchscreens are cost-effective, but only 75 percent of the light shows through, and until recently, multitouch was not possible.
  • Capacitive—A charged material layer is overlaid on a glass screen.When a finger or any conductive object touches the layer, some charge is drawn off, changing the capacitance, which is measured to determine the location of the touch. Capacitive touchscreens allow as much as 90 percent of the light through, although accuracy can be less than resistive.
  • Surface Acoustic Wave—This uses a more advanced method that sends and receives ultrasonic waves.When a finger or any object touches the screen, the waves are absorbed.
The waves are measured to determine the location of the touch. It is the most durable solution, but more suitable for large-scale screens such as automatic bank tellers.
All Android devices use either resistive or capacitive touchscreen technology, and with a few early exceptions, all support multitouch.
In addition, each Android device needs an alternative method to access the screen.This is through one of the following methods:
  • D-pad (directional pad)—An up-down-right-left type of joystick
  • Trackball—A rolling ball acting as a pointing device that is similar to a mouse
  • Trackpad—A special rectangular surface acting as a pointing device

Sensors
Smartphones are becoming sensor hubs in a way, opening a rich experience for users. Other than the microphone that every phone has, the first additional sensor introduced on phones was the camera. Different phone cameras have varying capabilities, and this is an important factor for people in selecting a device.The same type of diversity is now seen with the additional sensors.
Most smartphones have at least three basic sensors: a three-axis accelerometer to measure gravity, a three-axis magnetometer to measure the ambient magnetic field, and a temperature sensor to measure the ambient temperature. For example, the HTC Dream (G1) contains the following sensors (which can be displayed using getSensorList()

AK8976A 3-axis Accelerometer
AK8976A 3-axis Magnetic field sensor
AK8976A Orientation sensor
AK8976A Temperature sensor
The AK8976A is a single package from Asahi Kasei Microsystems (AKM) that combines a piezoresistive accelerometer, Hall-effect magnetometer, and temperature sensor. All provide 8-bit precision data.The orientation sensor is a virtual sensor that uses the accelerometer and magnetometer to determine the orientation.

For comparison, the Motorola Droid contains the following sensors:
LIS331DLH 3-axis Accelerometer
AK8973 3-axis Magnetic field sensor
AK8973 Temperature sensor
SFH7743 Proximity sensor
Orientation sensor type
LM3530 Light sensor

The LIS331DLH is a 12-bit capacitive accelerometer from ST Microelectronics. It provides much more accurate data and can sample up to 1kHz.The AK8973 is an AKM package with an 8-bit Hall-effect magnetometer and temperature sensor.
In addition, the Droid contains two more sensors.The SFH7743 is an Opto Semiconductor’s short-range proximity detector that turns the screen off when an object (such as the ear) is within about 40mm distance.The LM3530 is an LED driver with a programmable light sensor from National Semiconductor that detects ambient light and adjusts the screen backlight and LED flash appropriately.

One other example of sensors available on an Android device is the HTC EVO 4G, which has the following sensors:
BMA150 3-axis Accelerometer
AK8973 3-axis Magnetic field sensor
AK8973 Orientation sensor
CM3602 Proximity sensor
CM3602 Light sensor

The BMA150 is a Bosch Sensortec 10-bit accelerometer which can sample up to 1.5kHz.The CM3602 is a Capella Microsystems, Inc., short distance proximity sensor and ambient light sensor combined into one.
Overall, it is important to understand each Android model has different underlying hardware.These differences can lead to varying performance and accuracy of the sensors.


Features of Android
The detailed features of Android and how to take advantage of them provide a main theme throughout this book. On a broader level, some key features of Android are major selling points and differentiators. It is good to be aware of these strong points of Android and utilize them as much as possible.

Multiprocess and App Widgets
The Android OS does not restrict the processor to a single application at a time.The system manages priorities of applications and threads within a single application.This has the benefit that background tasks can be run while a user engages the device in a foreground process. For example, while a user plays a game, a background process can check stock prices and trigger an alert as necessary.
App Widgets are mini applications that can be embedded in other applications (such as the Home screen).They can process events, such as start a music stream or update the outside temperature, while other applications are running.
Multiprocessing has the benefit of a rich user experience. However, care must be taken to avoid power-hungry applications that drain the battery.These multiprocess .

Touch, Gestures, and Multitouch
The touchscreen is an intuitive user interface for a hand-held device. If utilized well, it can transcend a need for detailed instructions. After a finger touches the screen, drags and flings are natural ways to interact with graphics. Multitouch provides a way to track more than one finger down at the same time.This is often used to zoom or rotate a view.
Some touch events are available transparently to the developer without the need to implement their detailed behaviors. Custom gestures can be defined as needed. It is important to try to maintain a consistent usage of touch events as compared to other applications.These touch events are discussed further in other Chapter.

Hard and Soft Keyboards
One feature on a pocket device that galvanizes users is whether it should have a physical (also called hard) keyboard or software (also called soft) keyboard.The tactile feedback and definite placement of keys provided by a hard keyboard tends to make typing much faster for some, whereas others prefer the sleek design and convenience offered by a software- only input device.With the large variety of Android devices available, either type can be found.A side effect for developers is the need to support both. One downside of a soft keyboard is a portion of the screen needs to be dedicated to the input.This needs to be considered and tested for any user interface (UI) layout.

 

Android API Levels & Platform Versions


Android API Levels

As you develop your application on Android, it's useful to understand the platform's general approach to API change management. It's also important to understand the API Level identifier and the role it plays in ensuring your application's compatibility with devices on which it may be installed.
The sections below provide information about API Level and how it affects your applications.
For information about how to use the "Filter by API Level" control available in the API reference documentation, see Filtering the documentation at the end of this document.

What is API Level?

API Level is an integer value that uniquely identifies the framework API revision offered by a version of the Android platform.
The Android platform provides a framework API that applications can use to interact with the underlying Android system. The framework API consists of:
  • A core set of packages and classes
  • A set of XML elements and attributes for declaring a manifest file
  • A set of XML elements and attributes for declaring and accessing resources
  • A set of Intents
  • A set of permissions that applications can request, as well as permission enforcements included in the system
Each successive version of the Android platform can include updates to the Android application framework API that it delivers.
Updates to the framework API are designed so that the new API remains compatible with earlier versions of the API. That is, most changes in the API are additive and introduce new or replacement functionality. As parts of the API are upgraded, the older replaced parts are deprecated but are not removed, so that existing applications can still use them. In a very small number of cases, parts of the API may be modified or removed, although typically such changes are only needed to ensure API robustness and application or system security. All other API parts from earlier revisions are carried forward without modification.
The framework API that an Android platform delivers is specified using an integer identifier called "API Level". Each Android platform version supports exactly one API Level, although support is implicit for all earlier API Levels (down to API Level 1).
The initial release of the Android platform provided API Level 1 and subsequent releases have incremented the API Level.
The following table specifies the API Level supported by each version of the Android platform.


Platform VersionAPI LevelVERSION_CODENotes
Android 4.0.3 15 ICE_CREAM_SANDWICH_MR1 Platform Highlights
Android 4.0, 4.0.1, 4.0.2 14 ICE_CREAM_SANDWICH
Android 3.2 13 HONEYCOMB_MR2
Android 3.1.x 12 HONEYCOMB_MR1 Platform Highlights
Android 3.0.x 11 HONEYCOMB Platform Highlights
Android 2.3.4
Android 2.3.3
10 GINGERBREAD_MR1 Platform Highlights
Android 2.3.2
Android 2.3.1
Android 2.3
9 GINGERBREAD
Android 2.2.x 8 FROYO Platform Highlights
Android 2.1.x 7 ECLAIR_MR1 Platform Highlights
Android 2.0.1 6 ECLAIR_0_1
Android 2.0 5 ECLAIR
Android 1.6 4 DONUT Platform Highlights
Android 1.5 3 CUPCAKE Platform Highlights
Android 1.1 2 BASE_1_1
Android 1.0 1 BASE

Android Platform Versions

This page provides data about the relative number of active devices running a given version of the Android platform. This can help you understand the landscape of device distribution and decide how to prioritize the development of your application features for the devices currently in the hands of users. For information about how to target your application to devices based on platform version.







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.