Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
42 views

Android Programming

unit 1

Uploaded by

gopabandhukamila
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Android Programming

unit 1

Uploaded by

gopabandhukamila
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Introduction to Android

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

The above diagram shows some features of Android:

 Android is a powerful, open source, Linux – based operating system.


 It provides a rich development environment for building the applications.
 Android has a higher success ratio, because it reduces the development cost.
 Android has a large developer community which integrates the internal application.
 It has reached the top of the smart phone market segment and day by day its user base is
growing strong.
 Android supports audio, video formats like JPEG, PNG, GIF, BMP, MP3, MP4, MIDI, AMR,
AMR-WB, MPEG-4 etc
History of Android
 Android was developed by the Open Handset Alliance, led by Goggle.
 The first version of Android was released by Google in 2007 and the Android
version 1.0 was released in September 2008.
 In June 2012, Google announced the next Android version 4.1 Jelly Bean.
This version of Android is an incremental update which is mostly used for
improving the user interface.

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.

It provides customized ring tones, wallpapers and ability to


arrange apps (applications) and widgets across multiple screens
and in folders. The 'Speech-to-text' is introduced in this version
where your spoken words appear straight on your screen.

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.

It provides portable Wi-Fi hotspot into your phone where you


could stay connected even when on the go.

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.

It provides a new system bar which is enabled on-screen


navigation that controls your Android device. This version gives
rights to the user to access essential information easily like time,
date, battery life and connection status of your device all in one
place.

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.

It enables multiple users on one device. It provides an account


switching feature where each account has its own customized
space from the home screen to wallpaper, widgets and apps, so
user can share a device and not his/her information.

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.

It has immersive design which hides everything except what you


really want to see.

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

 Android is largely supported by Google allowing you to use various services


of Google.
 Android is an open source and runs on mobile devices, tablets etc.
 It is multitasking that means you can run many applications at the same
time. For example, you can browse Facebook while listening the song.
 The Android operating system is available on mobile phones from various
manufacturers like Samsung, Motorola, HTC, Sony Ericsson etc.
 Using Android phone, you can easily check e-mail from Gmail if your Gmail
account is integrated with Google Services.
 User can easily access a variety of settings quickly and easily.

Disadvantages of Android

 Android requires continuous Internet connection if you are using Google


services.
 Android shows error & forces to close the large apps/games, which is very
annoying.
 It takes large amount of mobile data if a large number of background
processes are running.
 It increases the usage of RAM and decreases battery performance when
many processes are running in the background.

Android Application Components

 Application components are the essential part of the Android operating


system which is used to build the Android applications.
 The AndroidManifest.xml file describes each component of the application
and how they interact.
Following are the Android Application Components,
1. Activities
2. Services
3. Content Providers
4. Broadcast Receivers
5. Intents

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.

 They respond to broadcast messages from other applications.


5. Intent
 Intent is a message which allows components to request activities from
other components.
There are two types of Intents,
1. Explicit Intents
2. Implicit Intents

1. Explicit intents are used for application's internal communications.

2. Implicit intent means sending a message to the Android system to find a


suitable activity that can be responded to the intent.

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.

It is categorized into five parts as below:


1. Linux Kernel
2. Native Libraries
3. Android Runtime
4. Application Framework
5. Applications
Each part of the stack and the elements within each layer are integrated and
provide optimal application development and execution environment for
mobile devices.
The following diagram shows the architecture of Android,

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.

Structure of Android Application


Developing an Android project, you have to install the Android plug-ins for
Eclipse and at least have some knowledge of Java programming.

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.

Every Android project contains several folders, like:

Folder Name Description

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.

Android 2.2 The Android Framework Library is stored here.

assets It is used to store raw asset files.

libs It contains private libraries.

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,

there are three types of drawable folders,


1. drawable-mdpi
2. drawable-hdpi
3. drawable-ldpi

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.

xml: It is used for configuring the application components.

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.

You might also like