Você está na página 1de 13

1. What is Android?

Android is a software stack for mobile devices that includes an operating system, middleware and key applications. Android is a software platform and operating system for mobile devices, based on the Linux kernel, and developed by Google and later the Open Handset Alliance. It allows developers to write managed code in the Java language, controlling the device via Google-developed Java libraries. Applications written in C and other languages can be compiled to ARM native code and run, but this development path is not officially supported by Google. The unveiling of the Android platform on 5 November 2007 was announced with the founding of the Open Handset Alliance, a consortium of 48 hardware, software, and telecom companies devoted to advancing open standards for mobile devices. Google released most of the Android code under the Apache license, a freesoftware and open source license.

WHY ANDROID
lopment over many platforms

For us
-based, easy to import 3rd party Java library funding (40+ G1 phones) Amazons kindle)

2. What is The Open Handset Alliance?


Open Handset Alliance, is a consortium of several companies which include Google, HTC, Intel, Motorola, Qualcomm, T-Mobile, Sprint Nextel and NVIDIA.These companies which aim to develop technologies that will significantly lower the cost of developing and distributing mobile devices and services. The Android platform is the first step in this direction -- a fully integrated mobile "software stack" that consists of an operating system, middleware, user-friendly interface and applications.

3. License
Android is under version 2 of the Apache Software License (ASL). The Apache license allows manufacturers and mobile operators to innovate using the platform without the requirement to contribute those innovations back to the open source community.

4. Features

Application framework enabling reuse and replacement of components Dalvik virtual machine optimized for mobile devices Integrated browser based on the open source WebKit engine Optimized graphics powered by a custom 2D graphics library; 3D graphics based on the OpenGL ES 1.0 specification (hardware acceleration optional) SQLite for structured data storage Media support for common audio, video, and still image formats (MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF) GSM Telephony (hardware dependent) Bluetooth, EDGE, 3G, and WiFi (hardware dependent) Camera, GPS, compass, and accelerometer (hardware dependent) Rich development environment including a device emulator, tools for debugging, memory and performance profiling, and a plug-in for the Eclipse IDE

5. Android Architecture
The following diagram shows the major components of the Android operating system. Each section is described in more detail below. Each layer uses the services provided by the below layers.

Applications
The highest layer in the android architecture layer is the Application layer. The End user will see only the application. Applications include an email client, SMS program, calendar, maps, browser, contacts, and others. All applications are written using the Java programming language.

Application Framework
By providing an open development platform, Android offers developers the ability to build extremely rich and innovative applications. Developers are free to take advantage of the device hardware, access location information, run background services, set alarms, add notifications to the status bar, and much, much more. Developers have full access to the same framework APIs used by the core applications. The application architecture is designed to simplify the reuse of components; any application can publish its capabilities and any other application may then make use of those capabilities (subject to security constraints enforced by the framework). This same mechanism allows components to be replaced by the user.

The most important parts of the framework are as follows: Activity manager: This controls the life cycle of applications and maintains a common backstack for user navigation. Content providers: These objects encapsulate data that needs to be shared between applications, such as contacts. Resource manager: Resources are anything that goes with the program that is not code. Location manager: An Android phone always knows where it is. Notication manager: Events such as arriving messages, appointments, proximity alerts, alien invasions, and more can be presented in an unobtrusive fashion to the user.

Libraries
Android includes a set of C/C++ libraries used by various components of the Android system. These capabilities are exposed to developers through the Android application framework. Some of the core libraries are listed below:

System C library - a BSD-derived implementation of the standard C system library (libc), tuned for embedded Linux-based devices Media Libraries - based on PacketVideo's OpenCORE; the libraries support playback and recording of many popular audio and video formats, as well as static image files, including MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG Surface Manager - manages access to the display subsystem and seamlessly composites 2D and 3D graphic layers from multiple applications

LibWebCore - a modern web browser engine which powers both the Android browser and an embeddable web view SGL - the underlying 2D graphics engine 3D libraries - an implementation based on OpenGL ES 1.0 APIs; the libraries use either hardware 3D acceleration (where available) or the included, highly optimized 3D software rasterizer FreeType - bitmap and vector font rendering SQLite - a powerful and lightweight relational database engine available to all applications

Android Runtime
This layer includes the Dalvik virtual machine and the core Java libraries. The Dalvik VM is Googles implementation of Java, optimized for mobile devices. All the code you write for Android will be written in Java and run within the VM. Whats a Dalvik? Dalvik is a virtual machine (VM) designed and written by Dan Bornstein at Google. Your code gets compiled into machine-independent instructions called bytecodes, which are then executed by the Dalvik VM on the mobile device. Although the bytecode formats are a little different, Dalvik is essentially a Java virtual machine optimized for low memory requirements. It allows multiple VM instances to run at once and takes advantage of the underlying operating system (Linux) for security and process isolation. Bornstein named Dalvik after a shing village in Iceland where some of his ancestors lived. The Dalvik VM executes files in the Dalvik Executable (.dex)
format which is optimized for minimal memory footprint. The VM is register-based, and runs classes compiled by a Java language compiler that have been transformed into the .dex format by the included "dx" tool.

Linux Kernel
Android relies on Linux version 2.6 for core system services such as security, memory management, process management, network stack, and driver model. The kernel also acts as an abstraction layer between the hardware and the rest of the software stack. Some of the core functions the kernel handles includes: Enforcement of application permissions and security Low-level memory management Process management and threading The network stack Display, keypad input, camera,WiFi, Flash memory, audio, and binder (IPC) driver access

6. Process! = Application
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 rst application they see is the Home application. This program typically shows the time, a background image, and a scrollable list of other applications the user can invoke. When the user runs an application, Android starts it and brings it to the foreground. From that application, the user might invoke another application, or another screen in the same application, and then another and another. All these programs and screens are recorded on the application stack by the systems Activity Manager. At any time, the user can press the Back button to return to the previous screen on the stack. From the users point of view, it works a lot like the history in a web browser. Pressing back returns them to the previous page. Internally, each user interface screen is represented by an Activity class. Each activity has its own life cycle. An application is one or more activities plus a Linux process to contain them. In Android, an application can be alive even if its process has been killed. Put another way, the activity life cycle is not tied to the process life cycle. Processes are just disposable containers for activities.

6.1 Life cycle of Android Activity:


During its lifetime, each activity of an Android program can be in one of several states, as shown in Figure on the following page. The developer, do not have control over what state your program is in.Thats all managed by the system. However, you do get notied when the state is about to change through the onXX () method calls. The programmer override these methods in the Activity class, and Android will call them at the appropriate time: onCreate(Bundle): This is called when the activity rst starts up. You can use it to perform one-time initialization such as creating the user interface. onCreate( ) takes one parameter that is either null or some state information previously saved by the onSaveInstanceState( ) method. onStart( ): This indicates the activity is about to be displayed to the user. onResume( ): This is called when your activity can start interacting with the user. This is a good place to start animations and music. onPause( ): This runs when the activity is about to go into the back ground, usually because another activity has been launched in front of it. This is where you should save your programs persistent state, such as a database record being edited. onStop( ): This is called when your activity is no longer visible to the user and it wont be needed for a while. If memory is tight, onStop( ) may never be called (the system may simply terminate your process). onRestart( ): If this method is called, it indicates your activity is being redisplayed to the user from a stopped state. onDestroy( ): This is called right before your activity is destroyed. If memory is tight, onDestroy( ) may never be called (the system may simply terminate your process).

onSaveInstanceState(Bundle): Android will call this method to allow the activity to save per-instance state, such as a cursor position within a text eld. Usually you wont need to override it because the default implementation saves the state for all your user inter face controls automatically. onRestoreInstanceState(Bundle): This is called when the activity is being reinitialized from a state previously saved by the onSaveInstanceState( ) method. The default implementation restores the state of your user interface.

7. Building Blocks of Android Applications:Quick-view


Android applications are composed of one or more application components (activities, services, content providers, and broadcast receivers) Each component performs a different role in the overall application behavior, and each one can be activated individually (even by other applications)

The manifest file must declare all components in the application and should also declare all application requirements, such as the minimum version of Android required and any hardware configurations required Non-code application resources (images, strings, layout files, etc.) should include alternatives for different device configurations (such as different strings for different languages and different layouts for different screen sizes).

Android applications are written in the Java programming language. The Android SDK tools compile the codealong with any data and resource filesinto an Android package, an archive file with an .apk suffix. All the code in a single .apk file is considered to be one application and is the file that Android-powered devices use to install the application.

7.1 Application Components


Application components are the essential building blocks of an Android application. Each component is a different point through which the system can enter your application. Not all components are actual entry points for the user and some depend on each other, but each one exists as its own entity and plays a specific roleeach one is a unique building block that helps define your application's overall behavior. Following are the types of application components. Each type serves a distinct purpose and has a distinct lifecycle that defines how the component is created and destroyed. Activities An activity represents a single screen with a user interface. For example, an email application might have one activity that shows a list of new emails, another activity to compose an email, and another activity for reading emails. Although the activities work together to form a cohesive user experience in the email application, each one is independent of the others. As such, a different application can start any one of these activities (if the email application allows it). For example, a camera application can start the activity in the email application that composes new mail, in order for the user to share a picture. An activity is implemented as a subclass of Activity class. Services A service is a component that runs in the background to perform long-running operations or to perform work for remote processes without user intervention. A service does not provide a user interface. For example, a service might play music in the background while the user is in a different application, or it might fetch data over the network without blocking user interaction with an activity. Another component, such as an activity, can start

the service and let it run or bind to it in order to interact with it. A service is implemented as a subclass of Service class. Content providers A content provider manages a shared set of application data. One can store the data in the file system, a SQLite database, on the web, or any other persistent storage location the application can access. Through the content provider, other applications can query or even modify the data (if the content provider allows it). For example, the Android system provides a content provider that manages the user's contact information. As such, any application with the proper permissions can query part of the content provider to read and write information about a particular person. Content providers are also useful for reading and writing data that is private to the application and not shared. A content provider is implemented as a subclass of ContentProvider and must implement a standard set of APIs that enable other applications to perform transactions. Broadcast receivers A broadcast receiver is a component that responds to system-wide broadcast announcements. Many broadcasts originate from the systemfor example, a broadcast announcing that the screen has turned off, the battery is low, or a picture was captured. Applications can also initiate broadcastsfor example, to let other applications know that some data has been downloaded to the device and is available for them to use. Although broadcast receivers don't display a user interface, they may create a status bar notification to alert the user when a broadcast event occurs. More commonly, though, a broadcast receiver is just a "gateway" to other components and is intended to do a very minimal amount of work. For instance, it might initiate a service to perform some work based on the event. A broadcast receiver is implemented as a subclass of BroadcastReceiver and each broadcast is delivered as an Intent object. A unique aspect of the Android system design is that any application can start another applications component. When the system starts a component, it starts the process for that application (if it's not already running) and instantiates the classes needed for the component. For example, if your application starts the activity in the camera application that captures a photo, that activity runs in the process that belongs to the camera application, not in your application's process. Therefore, unlike applications on most other systems, Android applications don't have a single entry point (there's no main() function, for example). Because the system runs each application in a separate process with file permissions that restrict access to other applications, your application cannot directly activate a component from another application. The Android system, however, can. So, to

activate a component in another application, you must deliver a message to the system that specifies your intent to start a particular component. The system then activates the component for you.

7.2 Activating Components


Three of the four component typesactivities, services, and broadcast receiversare activated by an asynchronous message called an intent. Intents bind individual components to each other at runtime (you can think of them as the messengers that request an action from other components), whether the component belongs to your application or another. Intent is created with an Intent object, which defines a message to activate either a specific component or a specific type of componentintent can be either explicit or implicit, respectively. For activities and services, intent defines the action to perform (for example, to "view" or "send" something) and may specify the URI of the data to act on (among other things that the component being started might need to know). For example, intent might convey a request for an activity to show an image or to open a web page. In some cases, one can start an activity to receive a result, in which case, the activity also returns the result in an Intent (for example, you can issue an intent to let the user pick a personal contact and have it returned to youthe return intent includes a URI pointing to the chosen contact). For broadcast receivers, the intent simply defines the announcement being broadcast (for example, a broadcast to indicate the device battery is low includes only a known action string that indicates "battery is low"). The other component type, content provider, is not activated by intents. Rather, it is activated when targeted by a request from a ContentResolver. The content resolver handles all direct transactions with the content provider so that the component that's performing transactions with the provider doesn't need to and instead calls methods on the ContentResolver object. This leaves a layer of abstraction between the content provider and the component requesting information (for security). The Manifest File Before the Android system can start an application component, the system must know that the component exists by reading the application's AndroidManifest.xml file (the "manifest" file). The application developer must declare all its components in this file, which must be at the root of the application project directory. The manifest does a number of things in addition to declaring the application's components, such as:

Identify any user permissions the application requires, such as Internet access or read-access to the user's contacts. Declare the minimum API Level required by the application, based on which APIs the application uses. Declare hardware and software features used or required by the application, such as a camera, Bluetooth services, or a multitouch screen. API libraries the application needs to be linked against (other than the Android framework APIs), such as the Google Maps library. And more

7.3 Application Resources


An Android application is composed of more than just codeit requires resources that are separate from the source code, such as images, audio files, and anything relating to the visual presentation of the application. For example, one should define animations, menus, styles, colors, and the layout of activity user interfaces with XML files. Using application resources makes it easy to update various characteristics of the application without modifying code andby providing sets of alternative resourcesenables you to optimize your application for a variety of device configurations (such as different languages and screen sizes). For every resource that you include in your Android project, the SDK build tools define a unique integer ID, which one can use to reference the resource from the application code or from other resources defined in XML. For example, if the application contains an image file named logo.png (saved in the res/drawable/ directory), the SDK tools generate a resource ID named R.drawable.logo, which you can use to reference the image and insert it in the application user interface.

ANDROID APPLICATION DEVELOPMENT:Developing applications for Android devices is facilitated by a group of tools that are provided with the SDK. You can access these tools through an Eclipse plug-in called ADT (Android Development Tools) or from the command line. Developing with Eclipse is the preferred method because it can directly invoke the tools that you need while developing applications. Following diagram depicts the different level of Android application development:

Figure . The development process for Android applications.

The development steps encompass four development phases, which include: Setup During this phase the developer install and set up the development environment. Also creates Android Virtual Devices (AVDs) and connect hardware devices on which he can install the applications. Development During this phase the developer set up and develops the Android project, which contains all of the source code and resource files for your application. Debugging and Testing During this phase you build your project into a debuggable .apk package that you can install and run on the emulator or an Android-powered device. If you are using Eclipse, builds are generated each time you project is saved. Next, you debug your application using a JDWP-compliant debugger along with the debugging and logging tools that are provided with the Android SDK. Eclipse already comes packaged with a compatible debugger. Last, you test your application using various Android SDK testing tools. Publishing During this phase you configure and build your application for release and distribute your application to users.

Android software development


Android software development is the process by which new applications are created for the Android operating system. Applications are usually developed in the Java programming language using the Android Software Development Kit, but other development tools are available. Android programming is done using Java syntax, plus a class library that resembles a subset of the Java SE library (plus Android-specific extensions).

Android SDK
The Android software development kit (SDK) includes a comprehensive set of development tools. These include a debugger, libraries, a handset emulator (based on QEMU), documentation, sample code, and tutorials. Currently supported development platforms include computers running Linux (any modern desktop Linux distribution), Mac OS X 10.4.9 or later, Windows XP or later. The officially supported integrated development environment (IDE) is Eclipse (currently 3.5 or 3.6) using the Android Development Tools (ADT) Plug-in, though developers may use any text editor to edit Java and XML files then use command line tools (Java Development Kit and Apache Ant are required) to create, build and debug Android applications as well as control attached Android devices (e.g., triggering a reboot, installing software package(s) remotely). Enhancements to Android's SDK go hand in hand with the overall Android platform development. The SDK also supports older versions of the Android platform in case developers wish to target their applications at older devices. Development tools are

downloadable components, so after one has downloaded the latest version and platform, older platforms and tools can also be downloaded for compatibility testing.
Android applications are packaged in .apk format and stored under /data/app folder on the Android OS (the folder is accessible only to root user for security reasons). APK package contains .dex files (compiled byte code files called Dalvik executables), resource files, etc.

Android Developer Tools


ADT (Android Developer Tools) is a plug-in for Eclipse that provides a suite of tools that are integrated with the Eclipse IDE. It offers you access to many features that help you develop Android applications quickly. ADT provides GUI access to many of the command line SDK tools as well as a UI design tool for rapid prototyping, designing, and building of your application's user interface.

Android Emulator
The Android SDK includes a mobile device emulator a virtual mobile device that runs on your computer. The emulator lets you develop and test Android applications without using a physical device. When the emulator is running, you can interact with the emulated mobile device just as you would an actual mobile device, except that you use your mouse pointer to "touch" the touch screen and can use some keyboard keys to invoke certain keys on the device.

Android Debug Bridge


ADB quick view Manage the state of an emulator or device Run shell commands on a device Manage port forwarding on an emulator or device Copy files to/from an emulator or device Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator instance or connected Android-powered device. It is a client-server program that includes three components: A client, which runs on your development machine. You can invoke a client from a shell by issuing an adb command. Other Android tools such as the ADT plugin and DDMS also create adb clients. A server, which runs as a background process on your development machine. The server manages communication between the client and the adb daemon running on an emulator or device. A daemon, which runs as a background process on each emulator or device instance.

Você também pode gostar