Android Programming
Android Programming
Android is an operating system which is based on the Linux kernel. Android system is also called
as Android Open Source Project (AOSP), lead by Google. Android is used for mobile devices, such as
smart phones and tablet computers. The Android application makes life more comfortable and
advanced for the users.
Features of Android
Android Description
Version
Android 1.6 This version comes in all shapes and sizes. It allows Android to
Donut run on a variety of screen resolutions and aspect ratios.
It has a quick search box that searches the result from the web,
from your phone's local content all at once from a single box on
the home screen.
Android 2.1 This version provides Google map navigation. For example, in
Eclair car navigation system, a forward looking 3D view, voice guidance
and traffic information all for free.
Android 2.2 This version provides voice capabilities which let you perform key
Froyo functions on your phone like searching, getting directions, making
notes, setting alarms and more with just the sound of your voice.
Android 2.3 This version provides gaming APIs. It builds rich, graphics-
Gingerbread intensive 3D games. This version introduces NFC (Near Field
Communication) which supports to transmit the information
between devices just by bringing them close together.
This version displays how much battery of your device has been
consumed, allows you to adjust the screen brightness, find out the
active applications.
Android 3.0 This version introduces tablet-friendly design with a larger layout
Honeycomb pattern. It enhances the experience of reading books, watching
videos, exploring maps and more.
Android 4.0 Ice This version provides Widgets which embed live app content
Cream Sandwich directly on your home screen that becomes more flexible to
customize the home screen.
It manages the network data usage. It tracks how much data you
used, set warning levels and hard limits and disable your service if
you reach the limit.
Android 4.1 Jelly This version provides actionable notifications which take action
Bean directly from the notification.
Android 4.4 This version helps to get the things done without touching the
KitKat mobile screen, just with the sound of your voice – just say “OK
Google” to launch voice search, send a text, get directions or even
play a song.
Android 5.0 This version has a bold visual style and the fluid tactile response
Lollipop of Material Design. It makes easier to navigate your device which
is based on the shadows and motion.
Using this version, user can move from phone to tablet. It works
on all devices, you can pick up where you left off with the songs,
apps, photos and even recent searches.
Android 6.0 This version is the latest android version, which provides last
Marshmallow longer battery life and new permissions that give you more
control.
Advantages of Android
Disadvantages of Android
1. Activities
Activity is also known as Widgets.
Activity represents a single screen with a user interface.
It is an individual user interface screen in an Android Application where
visual elements called Views.
It interacts with the user to do only one thing, such as unlock screen, dial a
phone, etc.
If new activity starts, then previous activity is stopped, but the data is
preserved.
An application consists of multiple activities.
For example, an email application has one activity to display a list of new
emails, another activity is to compose email, reading email and so on.
2. Services
Services performs the action without user interaction in the background, but
does not get initiated without user invocation.
It does not require a user interface.
It is an android application component which runs in a background and has
no visual UI.
It is used to perform the processing part of your application in the
background.
For example, music player application. When the music station is playing
the song, the user can open another application and the song plays in the
background.
3. Content Providers
Content providers are the android application component that provide a
flexible way to make data available across applications.
It manages common data based on permissions.
It manages the data which is being shared by more than one application.
Content provider is a critical concept that has led to develop in-house
android applications in a better way.
4. Broadcast Receivers
Broadcast receivers are used to receive messages which are broadcast by
the Android applications.
For example, the warning where the battery is getting low, change of time
zone, etc.
For example, the warning where the battery is getting low, change of time
zone, etc.
Android Architecture
Android architecture is a stack of software components. It is in the form of a
software application, operating system, run-time environment, middleware,
native libraries and services.
1. Linux Kernel
Linux is the heart of Android architecture.
It provides a level of abstraction between the hardware devices and the
upper layers of the Android software stack.
The Android operating system is based on the Linux kernel.
The Linux kernel is responsible for various device drivers such as Camera
driver, Display driver, Bluetooth driver, Keypad driver, Memory
management, Process management, Power management, etc.
2. Native Libraries
The native libraries such as Media, WebKit, SQLite, OpenGL, FreeType, C
Runtime library (libc) etc. are situated on the top of a Linux kernel.
Media library is responsible for playing and recording audio and video
formats, FreeType is for font support, WebKit is for browser support, SQLite
is for database, SSL is for Internet security etc.
3. Android Runtime
Android Runtime is the third section of the architecture and situated on the
second layer from the bottom.
Android Runtime includes core libraries and Dalvik Virtual Machine (DVM)
which is responsible to run android application.
Dalvik Virtual Machine (DVM) is like Java Virtual Machine (JVM) in Java, but
DVM is optimized for mobile Devices.
DVM makes use of the Linux core features like memory management and
multi-threading, which are essential in the Java language.
DVM provides fast performance and consumes less memory.
4. Application Framework
Application framework is situated on the top of the Native libraries and
Android runtime.
Android framework provides a lot of classes and interfaces for Android
application development and higher level services to the applications in the
form of Java classes.
It includes Android API's such as Activity manager, Window manager,
Content Provider, Telephony Manager, etc.
Activity manger is responsible for controlling all the aspects of the
application lifecycle and activity stack, Content provider is responsible for
allowing the applications to publish and share the data with the other
applications, View system is responsible for creating application user
interfaces, etc.
5. Applications
Applications are situated on the top of the Application framework.
The applications such as Home, Contact, Alarm, Calender, Camera,
Browsers, etc. use the Android framework which uses Android runtime and
libraries. Android runtime and Native libraries use Linux kernel.
The user can write his/her application to be installed on this layer only.
After installing all the plug-ins for an Android file, you can begin to develop
an Android application.
Android uses packages not only to arrange the code in an application but to
manage the application themselves.
The above diagram shows the basic building blocks of an Android application.
Android application in Eclipse or in any development tool have a pre-defined
structure with code and resource organized into a number of folders.
src The 'src' stands for Source Code. It contains the Java Source files.
gen The 'gen' stands for Generated Java Library. This library is for Android internal use only.
res The 'res' stands for Resource file. It can store resource files such as pictures, XML files, etc.
It contains some additional folders such as Drawable, layout and values .
anim: It is used for XML files that are compiled into animation objects.
color: It is used for XML files that describe colors.
drawable: It is used to store various graphics files. In Android project structure,
The above drawable folders are required in order to adapt to different screen resolutions.
layout: It is used for placing the XML layout files in the application
menu: It is used for defining the XML files in the application menu.
raw: The 'raw' stands for Raw Asset Files. These files are referenced from the application using a re
For example, good place for media is MP3 or Ogg files.
values: It is used for XML files which stores various string values, such as titles, labels, etc.
AndroidManifest.xml This file indicates the Android definition file. This file contains the information about the Android ap
Android version, permission to access Android device capabilities such as Internet access permission
default.properties This file contains the project settings, such as build the target. Do not edit this file manually. It should
Revision Control System.
Proguard.cfg This file defines how ProGuard optimizes and makes your code unclear.
MainLayout.xml This file describes the layout of the page. So all the components such as textboxes, labels, radio butto
application screen.
Activity class The application occupies the entire device screen which needs at least one class inherits from the Act
initiates the application and loads the layout page.