Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Mobile / Android

Article 1 - Introduction to Android

4.90/5 (25 votes)
3 Aug 2014CPOL14 min read 34.8K  
A comparative and brief description of Android, helpful for every beginner android developer.

Topics to be covered

Introduction

In recent times, mobile application development has been growing rapidly, both in terms of revenues and job scopes created by that field. This article is all about the brief summary and overview of mighty Android, the most emerging mobile application development platform now-a-days.

The article presents a clear comparing picture why developers should care about developing Android over other mobile platforms. Also a high-level overview of different layers of Android architecture stack and components of essential building blocks of an Android app are discussed here.  If you are an Android enthusiastic, like to play with code and would love to make amazing apps with it, let’s dive into the deep Android ocean!

                        Image 1

                                       (Source: http://www.spotrip.net/en/surf/app-surf-morocco/)

History of Android

We all know today, Google owns Android, right? But how many of us know the back history of Android? Yes, there was an exciting history behind today’s Google highlighted Android OS. Android Inc. was founded in October, 2003 by Andy Rubin, Rich Miner, Nick Sears and Chris White. And do know the funny part? Android was Andy Rubin’s nickname for his magnetism of robots. They were trying to build an OS for digital cameras at that time.

Well, the later history is huge. Let’s check some key points of that history to better understand the scenario. Rubin and his team later shifted their attention towards smartphone as of digital camera’s short market opportunities. Later his friend Steve Perlman pumped up Rubin’s work with $10,000 cash.

In 2005, Google bought Android Inc., later Rubin and his team devoted themselves to build a mobile device platform powered by Linux Kernel. In November 5, 2007, Google officially announced development of Android OS. Android Beta was released in that day, hence November 5 is Android’s birthday.The first commercial version, Android 1.0(API level 1) was released in September 2008 followed by SDK(software Development Kit) release in same month. First official codename “Cupcake” (Android 1.5, API level 3) was released on April 27,2009. We know the later history more or less, serially it was(by codename)- Donut(1.6), Éclair(2.0), Froyo(2.2), Gingerbread(2.3), Honeycomb(3.0), Ice Cream Sandwich(4.0), Jelly Bean(4.1), and now the most recent Kitkat(4.4).

Wait, probably one thing we need to know more. What about the famous cute logo of Android? Do any of you even think about it or know anything where it comes from? Well, in short it came from the famous Star War robot R2-D2. Current logo was designed by Irina Block though Dan Morrill designed some earlier versions of that logo.

                      Image 2

                                       Figure: Android Versions (Source: tech.firstpost.com)

Before Beginning

This articles is just the beginning of upcoming android development tutorial series following this one. So for development or you can read for coding an android app, you need to have good knowledge on JAVA and OOP, just to feel comfortable with android platform. If you feel you don’t have enough knowledge no problem, take some time to learn JAVA and OOP.

Welcome to Android

And finally welcome you to the  glamourous Android World. Do you feel excited to have a great start? Let’s dig inside.

What is Android?

Well, theoretically you can mean a robot with human appearances but technically it is an open-source operating system based on Linux kernel, currently owned and maintained by Google, was built mainly for smartphone and tablet devices. Keep one point in mind along with it, currently Android is the world’s most popular mobile OS. Do you notice the trend of smartphone apps all over the globe? Yes, you can consider Android is that change, who is leading from the front. 

Why Android?

Yes,at this stage probably you are thinking why you should develop apps in android, what’s the benefit over other well-established mobile OS in market. Definitely you are a good thinker!

                                                           Image 3

                                                      (Source : http://androidadvantage.blogspot.com/)

Let’s think wisely-

  • Android is an open-source OS, so it is free and open to use.
  • You must consider your app’s global distribution, right? There are number of parts of the world where other mobile OS are in no match with Android’s popularity(Consider China and other Asian countries, where 90% of smartphone’s OS are Android).
  • Android covers wide range of hardwares made by different manufacturers. So developers definitely have their advantages to use those hardware features.
  • Statistics of 2014 said, Android has 80.2% smartphone market share and 75% mobile application developers are developing apps for android platform. So do you feel the weight of the market of your next-app?
  • You can use your all development tools for free and can develop in your home with your pc(no matter you have a mac, windows or linux).
  • On Startup what requirements do you expect while publishing your app? A reasonable amount of developer registration fee, wide app distribution channel, bigger community etc. Android will provide them all. Google Play(Android app’s biggest market) developer registration only requires $25 to open account, too easy for beginners comparing with other mobile platform’s market.
  • User feedback is a very important point in case to increase app quality. Android has a big audience under its roof, you will get very quick responses from them after publishing your app. This directly leads you to enhance your app performance.
  • More or less developers or programmers know java and has a concept on OOP. So it’s far easier for them to get habituated in android platform in shortest possible time rather than other mobile platforms.
  • Android has a big developer community too. If you face a problem while writing your code, you will get immediate response from them which is very helpful for a newbie.
  • Android devices are cheap comparing with other mobile platforms. As a developer, you will often need to test your app in a real device before publishing it to a market. At that time, surely you will feel comfortable with Android for it’s cheap price.

So now you can think the inverse, why you don’t develop android apps beyond all these facilities! Find something or a reason not to start with it?

Android vs. Other: The Battle of Mobile OS!

Let’s take a close comparative look from a developer perspective on 3 mostly used Mobile OS in recent times(read Android vs. iOS vs. Windows Phone).

 

Android

iOS

Windows Phone

Developer

Google

Apple

Microsoft

Application Store

Google Play

App Store

Windows Phone Marketplace

Apps Available

1.2 million+

1.2 million+

245,000+

Core

Linux

Darwin

Windows NT

User Interface

Icon and Widgets

Icon-based

Tile-based

Developer Account Registration Fee

$25 once off

$99/year

$99/year

Main Programming language

JAVA

Objective-C

C#

Source Model

Open source

Closed-source

Closed-source

Market Share

80.2%

14.8%

3.5%

No. of users              (in millions)

900

600

12

No. of downloads per app

60,000

40,000

4,062

 

Overview of Android

Android Architecture Stack

You can consider Android OS as a software stack of different layers. Each layer is a group of program components and provide different services to the layer just above it.

Android architecture stack composed of 4 main layers :

  1. Linux Kernel
  2. Libraries along with Android Runtime
  3. Application Framework &
  4. Applications 

Linux Kernel

Positioned at the bottom of architecture stack and very basic layer of android system. Never interacts with developers or users but provide a level of abstraction between device hardware and other architecture layers.

Let’s check the functionalities of this layer to understand it’s importance:

  • Memory Management
  • Power Management
  • Hardware Abstraction
  • Process Management
  • Device Management
  • Security Settings
  • Network Stack
  • Hardware Drivers

So this layer makes the OS relatively painless to us completing all these weighty works, isn’t it?

Libraries

This layer contains all android native libraries. So what does it means by a library? A library contains a set of instructions to guide the device in handling different types of data. Basically they are written in C or C++ and responsible for a particular hardware.

Let’s check some native android key libraries and their function:

  • Webkit : Browser engine, allow web-browsing inside an app.
  • OpenGL : 3D graphics
  • SGL : 2D graphics
  • Surface Manager : Composite window manager on the screen.
  • SQLite  : Database engine, share and store application data
  • SSL : Internet security
  • Media : Allow recording and playback different media formats.
  • Libc : System C libraries.
  • Net : Provide access to network stack
  • Hardware : Provide access to hardware stuffs.
  • OS : Provide access to operating system services
  • Widget : Provide collection of UI components(i.e Button, Label etc)

Android Runtime

Consists of android core libraries along with a key component named Dalvik Virtual Machine, a java virtual machine optimized and designed specially for Android. Dalvik, developed by Dan Bornstein, doesn’t run .class files, instead it runs .dex files. .dex files are built from .class file at compilation time and ensures higher efficiency in low resource environment(i.e mobile and tablet devices). It is responsible for running apps on Android devices.

It allows multiple instance of VM to be created simultaneously providing process isolation,security memory management and threading support. Dalvik also provides a set of core libraries which enable application developers to write Android applications using standard Java programming language.

Application Framework

A layer with whom the applications directly interacts. Manages basic functions of a device. If you are an application developer, you need to deal with this service in your application.

Let’s check some key services that it provides:

  • Activity Manager – Manages activity lifecycle of an app.
  • Content Providers – Allow applications to share data with other applications.
  • Resource Manager – Manages various types of resources i.e strings, color settings inside our app.
  • Telephony Manager – Manages all voice calls. If we want to access voice calls in our application then we should use it.
  • Notifications Manager – Allows applications to display alerts and notifications to the user.
  • Location Manager – Provides access to the location services.Allows an application to receive updates about location changes using GPS or cell tower.

Applications

Topmost layer of Android Architecture stack. This is where our applications will fit, comprise both native and 3rd party applications installed by user. In a word, your written applications are going to be installed in this layer. Developers and users all care about this level from their perspective.

Some standard applications that comes pre-installed with every device are :

  • SMS
  • Dialer
  • Web browser
  • Contact manager
  • Email
  • Games etc.

 Let's view the architecture stack at a glance:

                       Image 4

Essential Building Blocks of an Android App

As an application developer you will need to use these blocks to build your android app. These blocks acts like a gateway through which the system can enter into your application. You can consider themselves as components as well.

An android application may be composed of several such components like Activity, Service or Intent. All of them should be defined in AndroidManifest.xml file(we will discuss it later what exactly this one is).

Let’s check some essential components that make up an android application functional.

Activity

Probably the most important component of an app, simply represents a single screen with an user interface. This is the component along which an user interacts with. Your application may consists of multiple activities that might be loosely bounded to each other.

So, simply you can think as a user, you have downloaded an app, click on the app icon and a page/screen/window appears with some image or data or whatever. Yes an or multiple activity acts behind the screen at that time.  As a developer think differently, you need to show or calculate or inform something in front of your users. So you need to handle Activity, your app performance will depend on how well you can manage your app’s activity state. Probably you got it, right?

Oh, we already heard about activity state above, so what’s that? Read this quote very very carefully-

Quote:

“The state of each activity is determined by its position on the activity stack, which contains all currently running activities. New activities are placed at the top of the stack. If the user navigates back using the Back button, or the foreground activity is otherwise closed, the next activity down on the stack moves up and becomes active.” (Source: http://www.cs.ccsu.edu/)

It’s time to check android activity life-cycle to have a clear impact how they works:

                Image 5

                                       Figure: Android Activity Life-cycle. (Source: Tutorialspoint.com)

So what are the functionalities of those app states, carry on reading:

  • onCreate(): Called when the activity is first created.
  • onStart(): Called when the activity becomes visible to the user.
  • onResume(): Called when the activity starts interacting with the user.
  • onPause(): Called when the current activity is being paused and the previous activity is being resumed.
  • onStop(): Called when the activity is no longer visible to the user.
  • onDestroy(): Called before the activity is destroyed by the system.
  • onRestart(): Called when the activity has been stopped and is restarting again.

Let's check some code example that gives your a practical experience about an activity lifecycle-

Java
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.widget.Toast;

public class MainActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        toast("In onCreate");
    }

    public void onStart() {
     super.onStart();
     toast("In onStart");
    }

    public void onRestart() {
     super.onRestart();
     toast("In onRestart");
    }

    public void onResume() {
     super.onResume();
     toast("In onResume");
    }

    public void onPause() {
     super.onPause();
     toast("In onPause");
    }

    public void onStop() {
     super.onStop();
     toast("In onStop.");
    }

    public void onDestroy() {
     super.onStop();
     toast("In onDestroy.");
    }

    private void toast(String string) {
        Context context = getApplicationContext();
        int duration = Toast.LENGTH_SHORT;
        Toast toast = Toast.makeText(context, string, duration);
        toast.show();
    }
}

Run above code in your android environment, probably now you will have a clear view about an activity.

Service

A component that runs in background, do long task behind user eye and doesn’t have a UI. That’s what an user can’t aware of it’s task. Often performs work for remote processes. Not has so many states like an activity, so easy to control, just start and stop it.

Well often we play a maze game or do some notes or chatting in facebook, along with our favourite music playing behind the screen. Yes, a service may play that music from eye-behind. And familiar with notification message on a android device? That’s also a service.

Content Provider

In short, this block or component store and retrieve data and make it accessible to all applications. You can store your data in an SQLite database or on the web or any other persistent storage location. Through the Content Provider , other applications can query or even modify the data (if the content provider allows it) .

Broadcast Receiver

A component that responds to system-wide broadcast announcements and registered as a receiver in an android app. Example may be a picture is captured or battery status. One more example is, while using an app by an user if a phone call comes in, the Broadcast Receiver will notify your app and your can do code to handle that interruption. This component doesn’t have any visual representation nor actively run in memory, you can send your own broadcasts from one part of your app to another, or a totally different app.

Points of Interest

As stated earlier in this article, Android is a vast vast sea to move on. This article clears some very basic and important points of android, it explains why you should move to android development and differences with other popular mobile application development platforms. A brief summary of android architecture and key components will grow up your interest behind the development. Before any development work in a new platform it’s very important to know the basic things of that platform and why you should feel interested to stay on that platform. Probably this article can answer you on most cases for Android. In upcoming articles, we will discuss about development for sure. Until then, have fun with Android. Happy droiding! 

                              Image 6

                                                    (Source: http://www.bewallpaper.com/)

 

Reference

Some useful reference for you that could enhance your knowledge:

Article History

11.08.2014 - Formatted with paragraph linking.

08.08.2014 - Corrected spelling mistake and code formatted.

07.08.2014 - Used image reference and Helpful website reference added.

06.08.2014 - Code sample added.

03.08.2014 - Main Article posted.

License

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