Quote

"Between stimulus and response there is a space. In that space is our power to choose our response.
In our response lies our growth and freedom"


“The only way to discover the limits of the possible is to go beyond them into the impossible.”


Friday, 10 February 2012

Android Application Architecture


Android is a software stack for mobile devices. The Android software stack includes an operating system, middleware and some supported applications. It also provides an SDK with tools and APIs required for developing applications for the Android platform. Android uses ‘Dalvik’ VM (an open source ‘process virtual machine’) for running applications on the android operating system. For an application to run on Android platform the Java programs are converted to JVM compatible ‘.class’ and then it is converted to Dalvik compatible format ‘.dex’(Dalvik executable). A single dex file can have multiple class files promoting space and resource optimization much needed for mobile devices which are constrained in terms of memory and processor speed. Android application code, data and resources are packaged in an archive with ‘.apk’ extension which is used for installation on the devices.  



Since the android operating system is Linux based hence it implements the principle of least privilege. This means that each application has only the privileges that it requires to perform the expected function. This increases the security in the android environment.
The android OS simulates the multi-user behavior and hence each application is like a user with minimum set of privileges to work as expected. Each application has an associated user ID which is the key to access various required resources in the android environment.  
Every process runs in its own Linux process and VM isolated from other VMs and application processes. However two applications can have the same ID and run in the same VM and Linux process for accessing each other resources.

Building blocks of the Android Application:

The building blocks of the android application also called as components are classified into four different types:

Activities:  An activity represents a single UI screen that enables a user to perform certain functions, such as taking photos or viewing contacts etc … Usually applications consist of multiple Activities to perform a set of functions. One of these activities should be defined as ‘main’ which is shown on application start-up. Other activities can then be started as required. When another activity is started then the current activity is moved to the ‘back stack’.  Every activity is a subclass of Activity class and its life-cycle is maintained by the callback methods, such as onCreate(), onStart(), onPause(),  onStop,  and onDestroy().  The activities must be declared in the applications manifest file.

Services: A service is a component that runs in the background to perform long-running operations or to perform work for remote processes. It does not provide any user interface and it can be started by another component using the startService() method. A service continues to run even when the user switches to another application. A service can be bound using the bindService() method. Binding enables us to interact with the service and perform Inter Process Communication. The services must be declared in the applications manifest file.

Content Providers: Content providers manage access to a structured set of shared data. The data stored on a file or a database can be queried or modified through a content provider. Content Providers provide interface to access data from one process to another process and enable you to implement data security in your application.

Broadcast receivers: A broadcast receiver is a component that responds to system-wide broadcast announcements, such as low battery. Broadcasts can originate from the system/device or an application. Broadcasts do not have a user interface associated with them but can send notification on the status bar to notify the user to initiate a service based on the event.

To start development on Android you can look at Android Development Quick Start.