Click here to Skip to main content
15,881,172 members
Articles / Mobile Apps / Android

Article1- Introduction to Android OS

Rate me:
Please Sign up or sign in to vote.
4.33/5 (17 votes)
5 Aug 2014CPOL14 min read 31.8K   17   10
This article gives you information about the history and architecture design of Android Operating System.It also covers the comparisons between various other Mobile Operating Systems.

Introduction

This article will make you understand the basics of Android Operating System and the architecture behind it. The topics which will be covered in the article are as follows :-

·         Brief summary of what Android is, how it compares to other mobile platforms, and why developers should care about developing Android.

·         High-level overview of different layers of Android Architecture stack (ie. Linux Kernel, Libraries, Android Runtime, Application Framework, Applications) and components that make up the essential building blocks of an Android app (i.e. Activities, Services, Broadcast Receivers, Content Providers)

Target Audience

This article is for the new developers or beginners who want to understand basics of Android Mobile Operating System. The audience could be high school kids who want to make school projects or upcoming developers who want to learn new technology to find opportunities in Android App Based Businesses.

Pre-requisites

No perquisites are required. This article itself contains sufficient information to understand the material.

Special Information

The important content for future reference is Italicized, they should be bookmarked for future articles.

Background

Brief summary about Android OS

In early days of technology, mobile phones were heavy and their operating systems were very limited in terms of usability and functionality .However, with new and better mobile processors, mobile operating system also developed and became mature.

Apple introduced its first IPhone in June 2007 with OS called IOS. It was a successful product and consumers were taken aback with the user experience. But it was closed source , thus other companies could not use it as operating system in their devices. Those companies also wanted to sell their mobile hardware devices, demanding rise of a new mobile operating system.

Open Handset Alliance between 84 companies was an important factor for Android's popularity. Along with that, Google's move to make Android open source made it a popular platform for development. Android gave provision to every mobile manufacturer to make custom UI for their own Mobile Hardware Devices and sell their own flavor of Android. In no time Android was widely adopted and accepted as a mobile operating system among developers as well as users because it was highly customizable and supported almost every variety of hardware.

  • History

Android Inc. which was a start-up company was acquired by Google in 2005.From 2005 to 2008, range of developments occurred in Android .The key players Andy Rubin, Rich Miner, Nick Sears, and Chris White had a goal  to allow applications (apps) to interact with one another and reuse components. This philosophy was also implemented with services, data and User Interfaces.

NOTE: Apps means Applications in mobile space.

The timeline of different versions of Android OS which is released by Google.

NOTE: Latest version of Android is 4.4 Kit Kat. Latest preview version is Android L for developers

history

  • What is Android?

Android is a stripped version of Linux Operating System i.e. it is compiled to run on smart phones and tablets which have fewer resources in terms of processing power and memory than a personal computer. However, it is still capable of doing daily productive jobs like word processing, sending emails , syncing , sharing , calling and other needs of communication. It had also become a main device of entertainment. You can stream videos, listen to music and play so many games by downloading apps from Google Play Market. Many of them are free. This operating system is Open Source and many phone manufacturers like Samsung, HTC, LG have launched new android devices both phones and tablets based on Android.

Android OS Basic
figure 1.2

Basics of Android UI (fig 1.2)

Home Screen- Home Screen is the main screen which you can very easily customize. You can add as many home screens (Depending on the vendor).

App Drawer- App drawer is the area where you can have all your apps installed and contains icons which you can bring on Home screen at any point by just holding and dragging and placing on the home screen.

Google Play Market- It’s a marketplace where you can buy and download free applications.

Search Bar- Its search bar which is integrated with OS such that you can search apps as well as search Google by typing anything in the search.

Navigation Bar- It contains back button, home button, and resent button.

Status Bar- Status bar is actually a notification bar which gives you info about pending information as well as important info like battery, radio signal, Wifi signal and time.

Notification Drawer - Notifications are the brief messages that user can access any time from the status bar. It provides updates; reminders or information which is important , but not critical enough. It could be opened by swiping down the status bar (notifications bar) fig 1.3

Notification Drawer
figure 1.3

 

Comparisons with Other Mobile Operating Systems

comparison with other mobile OSs

Why Android?

·         It's Open Source.

·         Gives you free apps.

·         Large app base.

·         Flexibility and easy to use interface.

·         Different hardware options from different manufacturers.

·         Widgets.

·         Cheaper devices.

·         Customizable UI using various ROMS like Cyanogenmod.

·         Live wallpapers.

·         Options to choose different keyboards like Swift Key.

Why need to learn Android?

·         More job opportunities.

·         All tools to develop Android App is free from Google.

·         Less developer fee which is 25$ one time.

·         Mass audience use android phone thus more vast consumers for the apps thus more revenue.

·         Lot of free tutorials and textual information available on internet to learn android.

·         Basic programming skills in Java are required.

·         Cheap hardware devices like Nexus 4 could be used to test apps which require real hardware.

·         More devices like smart watch and Android Wear uses same ecosystem thus little or more changes in app could be implemented and published.

·         Hassle free publication of applications in the marketplace.

Architecture of Android Operating System

Android Mobile Operating System is well laid out in terms of development. We can simply understand the whole architecture once we understand the philosophy behind this architecture which is:

Constraints in mobile OS

1.       Limited resources in terms of memory and processing power. When you see a phone with quad processor or octa core processor, do not get confused with your PC quad core processor. PC processors are more powerful then mobile processors and also there are no memory constraints in the system. Phone’s hardware especially processors are designed this way that they consume less power which takes us to next problem.

2.       More processing power means more battery usage. The mobile operating system should complement the processor to consume less battery and give optimum performance. This concludes why PC processors are different than the mobile processor.

3.       Telephony was the main priority; a smartphone should be able to do other things but no compromise on call making and many more.

Now to solve these problems developers came with solutions that really helped android to become the most successful operating system.

The solution was Dalvik, which was Google's inception. Dalvik VM takes the generated Java class files and combines them into one or more Dalvik Executable (.dex) files. Thus, code is more optimized to run on smaller devices. Also, by the use of ANR, application resources are released.

NOTE: ANR means Application Not Responding. VM means virtual machine.

In Android, application responsiveness is monitored by the Activity Manager and Window Manager System services. Android will display the ANR dialog for a particular application when it detects one of the following conditions:

·         No response to an input event (such as key press or screen touch events) within 5 seconds.

·         A Broadcast Receiver hasn't finished executing within 10 seconds.

  • New Runtime with Android L

In 2014 Google replaced Dalvik with new runtime which is ART. It is more optimized and gave more room for UI improvements. With version Android L polymer design is used to create animated UIs, which seemed to be more dependent on ART. But Google was able to implement ART today as we now have devices with octa core processors and 2 to 3 GB of RAM. Dalvik is still better for devices with lesser memories and lesser processing power.

  • Architecture Stack

Architecture of Android
figure 1.4

In the fig 1.4 at the bottom you can see Linux Kernel is responsible for power management, resources access and other OS duties. It also include device drivers and vendor specific drivers for camera, keypad etc.

Then on the next level you can see the native libraries which are C/C++ libraries to support graphics, audio, browser support and other inter process communication. SQLite offers support for database and content providers.

NOTE: The core libraries can change because they are all internal implementation
details of Android and not directly exposed to the published Android API. 

At Next level is the JAVA SDK which comes in handy for developers as it is high level API and used by developers to develop end user applications on top of this API.

NOTE: API refers to Application Programming Interface.

On the last Level , there are default apps for contacts management, calling, browsing, messaging and home screen which is deeply integrated with the OS.

Android UI

Android Ui

Android uses a UI framework that resembles other desktop based frameworks. It is a fourth generation UI framework. For e.g. Java based Swing UI is third generation. It uses XML for declaring interfaces (views).You load these XML view definitions as windows in your UI application. It is much similar to HTML based application. To get each element you use ID and get those elements in Java classes using those IDs and then you can manipulate them as the way you want.

Event text can also be separated from the screen which are static and are kept in different folder called res which means resources under Strings.xml file. This is done so that if you need to change language of the app, different string resources could be added easily.

Screens in Android UI are called Activities which comprises of multiple views. With Android version 3 fragments were introduced which gives more freedom and flexibility to UI developer.

Android Application Life Cycle 

Android Application Life Cycle

Image Reference - http://developer.android.com/training/basics/activity-lifecycle/starting.html

When an app starts, certain events occur those events are raised by system where developer has a chance to do something. For e.g. when you are taking a note in the note app and call comes in, your note app goes in background but the state of app and data in app should be saved before it is stopped. Those events could be easily handled by going through this application lifecycle. Thus these all methods are defined in the Activity class and you can easily write code in the methods by implementing them in your activity.

OnCreate - When activity is created.

OnStart - OnStart is called right after by OnCreate. OnStart can also be called from OnRestart. When OnStart is called your activity is not visible to the user but it is about to.

OnResume - OnResume will be called after OnStart just when activity is in foreground and accessible to the user.

OnPause - When user decides to move to another activity then System calls  OnPause on your activity.

OnStop - It is called when your activity becomes invisible to the user.

OnRestart - When your activity is called back from background to foreground after call to OnStop then onRestart is called

OnDestroy - If your activity sits on the activity stack but is not visible to the user and the system decides to kill your activity to save some resources then OnDestroy is called.

Building Blocks of Android Application

  • Activities
  • Services
  • Broadcast Receivers
  • Content Providers
  • Intents

Activities - An activity represents a single screen with user interface. For e.g. a contacts screen is one single activity which is different than a messaging a person using SMS screen which is another activity.

Services - Services are no different than the windows services which run in the background and have no interface. They just do their work on the background and do not stop unless user wanted them to stop. Some services should run always which are system services otherwise may lead to unpredictable behavior of OS. Services are bindable and unbindable . 

Content Provider- They acts as mediator between you app and data storage may be on your device or in cloud. For instance your contact app which is showing you the list of contacts is an activity and requesting hey content provider i need contacts to display then content provider listens the request and queries the data storage and gives results back to the activity. The actual process is little different but this example is the bigger picture just for understanding

Broadcast Receiver -It is a component that responds to  system-wide broadcast announcements. For example battery is low or no network etc. Apps can also broadcast a message and can show in the notification drawer.

Intents are asynchronous messages that bind individual components to each other at runtime. In simple words intents could be used to invoke different application from one app. Intent is an action that you can tell to Android to Invoke. For e.g. an application to call Phone.

Things and terms to remember before you dive in Android App Development (Gotcha's)

ADB- Android Debug Bridge - Very useful CMD tool comes with ADT could be used on Mac or Windows to use hardware device in debug mode or to use the emulator.

Emulator - It’s a virtual device which runs on computer and thus lets you test your app without using a physical device. But still if your application is using accelerometer features or front and back camera you still need a hardware device and run the app on the real device to see if the apps runs smoothly or to get the real performance of the app.

Log Cat – It is a very useful tool in Eclipse to debug code and applications. It logs every bit of small information when you run the app on the device. You can catch all events using this tool.

Best Practices for UI - You should be following Google's advice in terms of designing UI.A very good explanation is given on http://developer.android.com/index.html under design section.

Dashboard - It is used to publish your apps in the marketplace. It requires you to pay 25$ to get a developer's account to publish your app in marketplace.

Google API - You must use Google APIs for various services like maps or cloud in your application as they are easy to integrate and easy to use.

Eclipse Debugging - Always save the file and build your project before running the application. Most of the time if you have any error in xml files or in string files, they are hard to trace so make sure your xml markup are correct. By correct means that each tag is closed by the open tag and there is no spelling mistakes. Otherwise, sometimes new developers are unable to find the problem in the project and they get build error which is a common scenario.

Read the documentation thoroughly, once you have the confidence that you understood the concept of Android then dive in the app development. That helps a lot in long term. You can read all the documentation on http://developer.android.com/index.html .

Study more about design patterns and different architectural design which helps you write more manageable apps. For e.g. Inversion of control , Dependency Injection, Service Oriented Architecture etc.

You can download the complete developer’s tool with ADT from http://developer.android.com/index.html which is open source and free.

References

Image References -

http://developer.android.com/training/basics/activity-lifecycle/starting.html

Textual References -

  • Pro Android 4 , Apress
  • http://developer.android.com/index.html
  • http://visual.ly/comparison-mobile-os-android-ios-windows-and-blackberry
  • http://www.phonearena.com/news/Mobile-OS-comparison-Windows-Phone-8-vs-iOS-6.0-vs-Android-4.1_id31473

Points of Interest

In the process of writing this article i saw many facts which i myself were overlooked before. Android is fantastic framework and now giving all of us new opportunities. I don't see that any other platform or Mobile OS can dominate Android.

History

  • Version 1.0 - Published initial version of the article covering the required topics - 08/03/2014.
  • Version 1.1 - Image url fixed - 08/03/2014.
  • Version 1.2 - Fixed sizes of images and added ART section - 08/03/2014.
  • Version 1.3 - Added image references and made all notes bold - 08/22/2014.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Canada Canada
Microsoft Technologies - .Net 3.5/4.0/4.5 (VB/C#),WPF,XAML,Windows 8 development.Windows
Phone Development.

Architecture: Model View Controller (MVC), MVP, MVVM, Dependency Injection, Inversion of Control, Design Pattern,Service Oriented Architecture.

Database - SQL Server 2008/2012,LINQ.

DBMS: SQL Server Management Studio,

Web Technologies- ASP.Net Classic,ASP.Net MVC 4,WCF,HTML5,CSS3,Javascript.

Database Layer- ADO.Net,Entity Framework 4/5.

UI Frameworks - Telerik Silverlight and WPF Controls, Kendo UI.

Environment / IDE'S : Visual Studio 2008/ 2010/2012/2013,Team Foundation Server(Microsoft),



Open Source Technologies

Languages: Java,Php.

Mobile Development: Android,IOS Development.

Web-Services: Java EE,Servlets.

J2EE Technologies: Java Servlets/JSP ,Web Services, Java API For XML (JAXP): SAX ,DOM.

J2EE Business Components (EJB), Session Beans ,Entity Beans, Message Beans, JDBC,

Database: MySQL,DB2,ORACLE,Java Persistence API.

DBMS: SQL Server Management Studio, SQL Developer(Oracle).

Environment / IDE'S : Eclipse (Juno),Netbeans,JetBrains.

Javascript Frameworks: Breeze js, Require js,Angular js, Node js.

Mobile Frameworks: Cordova,Kendo Mobile.

Other Technologies: RabbitMq,Firebase,MongoDB,Pusher,Parser,Web RTC.

Comments and Discussions

 
GeneralMy vote of 4 Pin
Muhammad Shahid Farooq27-Dec-16 22:24
professionalMuhammad Shahid Farooq27-Dec-16 22:24 
GeneralMy vote of 3 Pin
ridoy13-Aug-14 18:10
professionalridoy13-Aug-14 18:10 
GeneralRe: My vote of 3 Pin
Riju_Vashisht14-Aug-14 5:33
Riju_Vashisht14-Aug-14 5:33 
GeneralRe: My vote of 3 Pin
ridoy14-Aug-14 6:17
professionalridoy14-Aug-14 6:17 
GeneralMy vote of 5 Pin
Debabrata_Das5-Aug-14 7:36
professionalDebabrata_Das5-Aug-14 7:36 
GeneralRe: My vote of 5 Pin
Riju_Vashisht5-Aug-14 11:58
Riju_Vashisht5-Aug-14 11:58 
GeneralThanks for the entry! Pin
Kevin Priddle5-Aug-14 7:02
professionalKevin Priddle5-Aug-14 7:02 
GeneralRe: Thanks for the entry! Pin
Riju_Vashisht5-Aug-14 7:31
Riju_Vashisht5-Aug-14 7:31 
SuggestionSuggestion Pin
Ranjan.D3-Aug-14 4:49
professionalRanjan.D3-Aug-14 4:49 
GeneralRe: Suggestion Pin
Riju_Vashisht3-Aug-14 6:09
Riju_Vashisht3-Aug-14 6:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.