Saturday, 22 September 2012

Android Application Architecture

 Manifest File

The manifest file glues everything together. It is this file that explains what the application
consists of, what all its main building blocks are, what permissions it requires,
and so on
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.programing.tutorials" android:versionCode="1" android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".HelloWorld" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="8" />
</manifest>

 Layout XML Code

 The layout file specifies the layout of your screen. In this case, shown in Example,
we have only one screen, and it’s loaded by the HelloWorld.java code seen in Example

Example 
 res/layout/main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/hello" />
</LinearLayout>


 Strings

This is another XML file that contains all the text that your application uses. For example,
the names of buttons, labels, default text, and similar types of strings go into
this file. This is the best practice for separating the concerns of various files, even if they
are XML files. In other words, layout XML is responsible for the layout of widgets, but
strings XML is responsible for their textual content (see Example).
Example  res/values/strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, HelloWorld!</string>
<string name="app_name">Hello, World!!!</string>
</resources>

 The R File

The R file is the glue between the world of Java and the world of resources (see Example). It is an automatically generated file, and as such, you never modify it. It is
recreated every time you change anything in the res directory, for example, when you
add an image or XML file.
You don’t need to look at this file much. We will use the data in it quite a bit, but we’ll
use Eclipse to help us refer to values stored in this file.
Example  R.java
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package android.programing.tutorial;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
}
 
Java Source Code

The Java code is what drives everything. This is the code that ultimately gets converted
to a Dalvik executable and runs your application (see Example ).
 
Example  HelloWorld.java
 
package android.programing.tutorial;
import android.app.Activity;
import android.os.Bundle;
public class HelloWorld extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
 setContentView(R.layout.main);
}
}



Android and Java

In Java, you write your Java source file, compile it into a Java byte code using the Java
compiler, and then run this byte code on the Java VM. In Android, things are different.
You still write the Java source file, and you still compile it to Java byte code using the
same Java compiler. But at that point, you recompile it once again using the Dalvik
compiler to Dalvik byte code. It is this Dalvik byte code that is then executed on the
Dalvik VM. Figure illustrates this comparison between standard Java (on the left)
in Android using Dalvik (on the right).


Android Architecture




Linux Kernel

At the root of this architecture is the Linux Kernel 2.6. As known to everyone, Linux is a fully open source operating system, thus Android is also a totally open source system. Any individual or company can get the source code at http://developer.android.com/ . The Linux kernel provided the core components for interaction with mobile phone hardware. Well, like the operating system for PC, it provides management for many resources, memory, process, network, etc. However, the Android version of Linux distinguishes itself from the normal Linux in that: it provides customized management for handset hardware which are greatly differ from PC. The following lists some aspects requiring special attention when customize Linux for Handset mobile.

  •     Power
  •     Flash Memory
  •     Keypad
  •     Wifi
 
System Library


Stacked on the Linuxe Kernel, Google integrated many libraries into Android, tailored to mobile handset needs:
  • SQLite, a lightweight database engine used a lot in Google's applications to store data. For example, all cookie and history information of Chrome browser use SQLite to store cache locally.
  • WebKit, a browser engine that is also used in Chrome.
  • SSL: for certification and encryption.
  • OpenGL: for 2D and 3D graphic.
  • Media Framework: photos, video, etc.
 
Applications 

 At this top layer, you will find applications that ship with the Android device
(such as Phone, Contacts, Browser, etc.), as well as applications that you download and install
from the Android Market. Any applications that you write are located at this layer.

Dalvik Virtual Machine

Dalvik is a purpose-built virtual machine designed specifically for Android, developed
by Dan Bornstein and his team at Google.
The Java virtual machine (VM) was designed to be a one-size-fits-all solution, and the
Dalvik team felt they could do a better job by focusing strictly on mobile devices. They
looked at which constraints specific to a mobile environment are least likely to change
in the near future. One of these is battery life, and the other is processing power. Dalvik
was built from the ground up to address those constraints.

 Another side effect of replacing the Java VM with the Dalvik VM is the licensing.
Whereas the Java language, Java tools, and Java libraries are free, the Java virtual machine
is not. This was more of an issue back in 2005 when the work on Dalvik started.
Nowadays, there are open source alternatives to Sun’s Java VM, namely the
OpenJDK and Apache Harmony projects.
By developing a truly open source and license-friendly virtual machine, Android yet
again provides a full-featured platform that others are encouraged to adopt for a variety
of devices without having to worry about the license


Application Framework

The application framework is a rich environment that provides numerous services to
help you, the app developer, get your job done. This is the best-documented and most
extensively covered part of the platform because it is this layer that empowers developers
to get creative and bring fantastic applications to the market.
In the application framework layer, you will find numerous Java libraries specifically
built for Android. You will also find many services (or managers) that provide the ecosystem
of capabilities your application can tap into, such as location, sensors, WiFi,
telephony, and so on.

Friday, 21 September 2012

Android Versions

Android has gone through quite a number of updates since its first release.
versions of Android and their codenames.


Android

Android is a Linux-based operating system designed primarily for touchscreen mobile devices such as smartphones and tablet computers, developed by Google in conjunction with the Open Handset Alliance.

Open Handset Alliance, a consortium of 86 hardware, software, and telecommunication companies devoted to advancing open standards for mobile devices.

 Android, Inc. was founded in Palo Alto, California, United States in October 2003 by Andy Rubin (co-founder of Danger),  Rich Miner (co-founder of Wildfire Communications, Inc.) Nick Sears (once VP at T-Mobile) and Chris White (headed design and interface development at WebTV)

Google acquired Android Inc. on August 17, 2005, making Android Inc. a wholly owned subsidiary of Google. Key employees of Android Inc., including Andy Rubin, Rich Miner and Chris White, stayed at the company after the acquisition.
  
At Google, the team led by Rubin developed a mobile device platform powered by the Linux kernel. Google marketed the platform to handset makers and carriers on the promise of providing a flexible, upgradable system. Google had lined up a series of hardware component and software partners and signaled to carriers that it was open to various degrees of cooperation on their part

On November 5, 2007, the Open Handset Alliance, a consortium of technology companies including Google, device manufacturers such as HTC and Samsung, wireless carriers such as Sprint Nextel and T-Mobile, and chipset makers such as Qualcomm and Texas Instruments, unveiled itself. The goal of the Open Handset Alliance is to develop open standards for mobile devices. On the same day, the Open Handset Alliance unveiled Android as its first product, a mobile device platform built on the Linux kernel version 2.6.

 The first commercially available phone to run Android was the HTC Dream, released on October 22, 2008. In early 2010 Google collaborated with HTC to launch its flagship Android device, the Nexus One. This was followed later in 2010 with the Samsung-made Nexus S and in 2011 with the Galaxy Nexus.