Wednesday, September 14, 2011

Understanding Android Architecture Fundamental Components


Understanding Android Applications
Android applications are written in the Java programming language. The Android SDK tools compile the code—along with any data and resource files—into 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.

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 role—each one is a unique building block that helps define your application's overall behavior.

The fundamental building blocks / components of Android are:
1. Activities
2. Services
3. Broadcast Receivers
4. Content Providers.

Activities
An activity represents a single screen with a user interface(one single screen). 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.
An activity is implemented as a subclass of Activity.

Services
A service is a component that runs in the background to perform long-running operations or to perform work for remote processes. A service does not provide a user interface. For example,  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.
 
 Broadcast receivers
A broadcast receiver is a component that responds to system-wide broadcast announcements. Many broadcasts originate from the system—for example, a broadcast announcing that the screen has turned off, the battery is low, or a picture was captured. 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.


Content providers
A content provider manages a shared set of application data. You can store the data in the file system, an SQLite database, on the web, or any other persistent storage location your 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 (such as ContactsContract.Data) to read and write information about a particular person.
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. For more information, see the Content Providers developer guide.

What is Android Architecture


Android is a software stack for mobile devices that includes an operating system, middleware and key applications.
The following diagram shows the major components of the Android operating system.


Components of the Android architecture: 

1. Applications: These are applications written in Java. Some of basic applications include a calendar, email client, SMS program, maps, making phone calls, accessing the Web browser, accessing your contacts list and others.
If you are a mobile user, this is the layer you will use most, rest all layers are used by Google programmers, developers and hardware manufacturers. 

2. Application Framework: This is the skeleton or framework which all android developers have to follow. The developers can access all framework APIs an manage phone’s basic functions like resource allocation, switching between processes or programs, telephone applications, and keeping track of the phone’s physical location. 

The architecture is well designed to simplify the reuse of components. Think of the application framework as a set of basic tools with which a developer can build much more complex tools.
3. Libraries: This layer consists of Android libraries written in C, C++, and used by various systems. These libraries tell the device how to handle different kinds of data and are exposed to Android developers via Android Application framework. Some of these libraries includes media, graphics, 3d, SQLite, web browser library etc.
The Android runtime layer which includes set of core java libraries and DVM (Dalvik Virtual Machine) is also located in same layer. 

4. Runtime Android: This layer includes set of base libraries that are required for java libraries. Every Android application gets its own instance of Dalvik virtual machine. Dalvik has been written so that a device can run multiple VMs efficiently and it executes files in executable (.Dex) optimized for minimum memory.
5. Kernel – Linux: This layer includes Android’s memory management programs, security settings, power management software and several drivers for hardware, file system access, networking and inter-process-communication. The kernel also acts as an abstraction layer between hardware and the rest of the software stack.

Why android and its advantage

Android's share of the smartphone market is blowing away all competitors in the U.S. according to new data from comScore.


Most important it supports Java, which gives highly importance for that because its platform independent and its Open source software where others will not compete in this regard.