You are on page 1of 32


Android Programing
Android APIs, Android Architecture
Application Framework
The Application components
The manifest file
Downloading and installing Android
Exploring the Development Environment
Developing and Executing the first Android application,
Working with Activities
The LinearLayout Layout
The RelativeLayout Layout
The ScrollView Layout
The TableLayout Layout
The FrameLayout Layout
Using the TextView,EditText View,Button View,RadioButton,
CheckBox, ImageButton, RatingBar,
The options Menu
The Context Menu

What is Android?
Android is a mobile operating system based on the linux and kernel. It's
maintained by Google, and comes in a few different versions. At the time of
writing, mobile phones run a variant of version 2 of Android, while most
new tablets run a variant of version 3.
Android's standard layout is to have a series of Home screens, which can
contain shortcuts to launch apps, or can contain widgets, which are small
programs that serve a single function, such as controlling your music or
displaying Facebook updates.

Free and open source linux based operating system,

Developed by Open Handset Alliance,
Provides unified approach to application development,
Provides SQLite relational database, webkit open source web
App development in JAVA programming language using Android
Primary app store Google Play,
Software required: JAVA JDK, Android SDK
History and version of Android
It is very interesting to know history and version of android.

Android was founded by Andy Rubin, Rich Minner, and Charris White.
The early intentions of the company were to develop an advanced operating
system for digital cameras, when it was realized that the market for the
devices was not large enough, and diverted their efforts to producing a smart
phone operating system to rival those of Symbian and Windows Mobile.
Initially android was developed for Television, video games, digital cameras
and electronics.
Later android apps were shifted to mobiles.
After 2 years Google bought the Android in 2005.
In 2007 Google officially announced development of Android OS.
Features are going to be added one version to another version.
Versions of Android
Versions of Android
Version Code name API

1.5 Cupcake 3

1.6 Donut 4

2.1 Eclair 7

2.2 Froyo 8

2.3 Gingerbread 9 and 10

3.1 and 3.3 Honeycomb 12 and 13

4.0 Ice Cream Sandwitch 15

4.1, 4.2 and 4.3 Jelly Bean 16, 17 and 18

4.4 KitKat 19
Architecture of Android
Architecture of Android

Linux Kernel:
A level of abstraction between the device hardware.
Contains all the essential hardware drivers like camera, keypad,
display etc.
Interfacing with hardware.
Provides JAVA - based set of libraries like libc, SQLite, SSL,
web browser engine and C/C++ libraries to facilitate interface
building, graphics drawing, and database access.
Architecture of Android
Android Libraries:
Provides access to application model, cornerstone for all apps.
Facilitate content access, publishing, and messaging between,
applications and application components,
Used to access data from database also includes SQLite DBMS
JAVA interface to the OpenGL 3D graphics rendering API,
Architecture of Android
Android Libraries:
provides applications with access to standard operating system
services like interprocess communication, system services,
renders and manipulates text on a device display,
building block of application user interface,
provides pre-built UI components viz. Buttons, labels, list views,
radio buttons,
allow web browsing to be built into applications.
Architecture of Android
Android Runtime

Provides Dalvik Virtual Machine which is a kind of JAVA virtual

machine specifically designed and optimized for Android.
The Dalvik VM make use of Linux Core features like memory
management and multithreading, which is intrinsic(natural or
fundamental) in the java language.
The Dalvik VM enables every Android applications to run its own
process, with its own instance of the Dalvik virtual machine.
The Android rumtime also provides a set of core libraries which
enable Android application developers to write Android
Applications using standard JAVA programming language.
Architecture of Android
Application Framework

Provides higher level services to applications in form of JAVA

Android developers are allowed to make use of these services in
their applications.
It includes:
Activity Manager: Controls all aspects of the application
Content Providers: Allows applications to publish and share data
with other applications.
Resource Manager: Provides access to color settings, UI layouts.
Notification Manager: Allows applications to display alerts and
notifications to the user.
View System: Used to create application UI.
Architecture of Android

You will find all the Android application at the top layer.
You will write your application to be installed on this layer only.
Example of such applications are Contacts Bokks, Browser, and
Ganes etc.
Application Components
Loosely coupled by the application manifest file
AndroidManifest.xml that describes each component of the
application and their interaction with each other.
1. Activity,
2. Service,
3. Broadcast Receiver,
4. Content Provider;
Android core building block
A component is simply a piece of code that has a well defined life cycle. e.g.-Activity, Receiver,
service etc.
The core building blocks or fundamental components of android are activities, views, intents,
services, content providers, fragments and AndroidManifest.xml.

An activity is a class that represents a single screen. It is like a frame in AWT.

A view is the UI element such as button, label, text, field etc.
Anything that you see is a view.

intent is used to invoke components. It is mainly is used to:
Android core building block
Start the service
Launch an activity
Display a web page
Display a list of contacts
Broadcast a message
Dial a phone call etc.

Service is background process that can run for a long time.
Content provider
Content provider are used to share data between the applications.
Fragment are like part of activity. An activity can display one or more
fragments on the screen at the same time.
It contains information about activities, content provider, permissions etc.
How to set up Android for eclipse IDE
There are following steps required for set up eclipse IDE:
1. Install JDK
2. Download and install the eclipse for developing android application
3. Download and install the android SDK
4. Install the ADT plugin for eclipse
5. Configure the ADT plugin
6. Create AVD
7. Create the hello android application
For more info visit:
How to make android apps
In this page we are creating the simple example of android using eclipse
1. Create new android project
2. Write the message
3. Run the android application
Simple android example
Hello android example
1) Create a new android project
1. select File>New>Project..
2. select android project and click next
3. Fill the details in this dialog box and click finish
2) write the message
package com.example.helloandroid;
import android.os.Bundle;
import android.view.Menu;
import android.widget.TextView;

public class MainActivity extends Activity {

protected void onCreate(Bundle savedInstanceState) {

TextView textview=new TextView(this);

textview.setText("Hello Android!");

public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(, menu);
return true;

3) Run the android application
right click on the project >run as..>android application
Internal working of hello android example
Android UI widgets
There are many UI widgets with simple example such as button edittext,
autocompletetextview, togglebutton, datepiker, timepicker, progressbar etc.
Working with buttons
Learn how to perform event handling on button click.
Android toast
Displays information for the short duration of time.
Custom toast
we can display the image on toast.
Check box
application of simple food ordering.
Toggle button
it has two states on/off.
Alert dialog
Alert dialog containing the message with ok and cancel buttons.
display the multiple options but only selected at a time.
Ratingbar display rating bar.
datepicker displays datepicker dialog that can be used to pick the date.
it can be used to pick the time.
Android lifecycle of Activity
Android fragments
A fragment is an independent component which can be used by an activity.
Fragments represents multiple screen inside one activity.
A fragment runs in the context of an activity, but has its own life cycle and
typically its own user interface. It is also possible to define fragments
without an user interface, i.e., headless fragments.
Advantages of using fragments
Fragments make it easy to reuse components in different layouts, e.g., you
can build single-pane layouts for handsets (phones) and multi-pane layouts
for tablets.
This is not limited to tablets; for example, you can use fragments also to
support different layout for landscape and portrait orientation on a