UNIT:2Introduction to Android1

Syllabus2.1 Overview of Android 2.2 What does Android run On – Android Internals? 2.3 Android for mobile apps development 2.5 Environment setup for Android appsDevelopment 2.6 Framework - Android- SDK, Eclipse 2.7 Emulators – What is an Emulator /AndroidAVD? 2.8 Android Emulation – Creation and set up 2.9 First Android Application 2

2.1 OVERVIEW OF ANDROIDAndroid is an open source and Linux-basedOperating System for mobile devices such assmart phones and tablet computers. It was developed by Andy Rubin.(Father ofAndroid) Android was introduced by the Open HandsetAlliance, lead by Google, and other companies. Android is an open source operating system, so itallows developer to create their application atfree of cost. 3


HISTORY OF ANDROID The code names of android ranges from A to Lcurrently, such as Aestro, Blender, Cupcake,Donut, Eclair, Froyo, Gingerbread, Honeycomb,Ice Cream Sandwitch, Jelly Bean, KitKat andLollipop.5

2.2 WHAT DOES ANDROIDANDROID INTERNALS?RUNON –During startup of the Android system the Linux kernelfirst calls the process "init". init reads the files "/init.rc"and "init.device.rc". "init.device.rc" is device specific, onthe virtual device this file is called "init.goldfish.rc". init.rc starts the process "Zygote" via the program"/system/bin/app process". Zygote loads the core Javaclasses and performs initial processing of them. Theseclasses can be reused by Android application andtherefore this step makes them faster to start. Once theinitial work of Zygote is done, the process listens to asocket and waits for requests. 6

A special driver called Binder allow an efficientinterprocess communications (IPC) in whichallow references to objects are passed betweenprocesses. The real objects are stored in SharedMemory. This way the communication betweenthe processes is optimized as less data must betransferred.7

2.3 ANDROIDFOR MOBILE APPSDEVELOPMENT Features of AndroidOpen Source:Beautiful UI:Android OS basic screen provides a beautiful user interface.Connectivity:GSM/EDGE, IDEN, CDMA, EV-DO, UMTS, Bluetooth, WiFi, LTE, NFC and WiMAX.Storage:SQLite, a lightweight relational database, is used for datastorage purposes.Media support:H.263, H.264, MPEG-4 SP, AMR, AMR-WB, AAC, HE-AAC,AAC 5.1, MP3, MIDI, Ogg Vorbis, WAV, JPEG, PNG, GIF,and BMP8Messaging:Supports SMS and MMS

Web browser:Based on the open-source WebKit layout engine, coupledwith Chrome's V8 JavaScript engine supporting HTML5and CSS3. Multi-touch:Android supports multi-touch screen (which wasinitially made available in handsets such as the HTCHero.) Multi-tasking:User can jump from one task to another and same timevarious application can run simultaneously. Resizable widgets:Widgets are resizable, so users can expand them to showmore content or shrink them to save space9

2.5 ENVIRONMENT SETUP FORANDROID APPS DEVELOPMENTInstall Java JDK Install Android SDK Install Eclipse IDE Android Development Tools (ADT) EclipsePlug-in (optional) 10


Install required packages.12

If you agree to install all the packages, selectAccept All radio button and proceed by clickingInstall button. Once all the packages are installed, you can closeSDK manager using top-right cross button. 13

SET-UP ECLIPSE IDETo install Eclipse IDE, download the latestEclipse binaries from Once you downloaded the installation, unpackthe binary distribution into a convenient location.For example in C:\eclipse on windows, or/usr/local/eclipse on Linux and finally set PATHvariable appropriately. Eclipse can be started by simply doubleclick on eclipse.exe After a successful start up, if everything is finethen it should display following result 14


SET-UP ANDROID DEVELOPMENT TOOLS(ADT) PLUG-IN This step will help you in setting AndroidDevelopment Tool plug-in for Eclipse. Let's startwith launching Eclipse and then, choose Help Software Updates Install New Software.This will display the following dialogue box.16


Now use Add button to add ADT Plug-in asname and as thelocation. Then click OK to add this location, as soon as youwill click OK button to add this location, Eclipsestarts searching for the plug-in available thegiven location and finally lists down the foundplug-ins. 18

Now select all the listed plug-ins usingSelect All button and click Next button19

2.6 FRAMEWORK - ANDROID- SDK,ECLIPSE Android operating system is a stack of softwarecomponents which is roughly divided into fivesections and four main layers as shown in thearchitecture diagram.Linux kernel Libraries Android Runtime Application Framework Applications 20


1. Linux kernel:At the bottom of the layers is Linux This provides a level of abstraction between thedevice hardware and it contains all hardware driverslike camera, keypad, display etc. Also, the kernel handles all the things that Linux isreally good at such as networking and a vast array ofdevice drivers, which take the pain out of interfacingto peripheral hardware. 22

2. Libraries:On top of Linux kernel there is a set of librariesincluding open-source Web browser engine WebKit, wellknown library libc, SQLite database which is a usefulrepository for storage and sharing of application data,libraries to play and record audio and video, SSLlibraries responsible for Internet security etc.3. Android Runtime: This is the third section of the architecture andavailable on the second layer from the bottom. This section provides a key component called DalvikVirtual Machine which is a kind of Java VirtualMachine specially designed and optimized for Android. 23

The Android runtime also provides a set of corelibraries which enable Android application developersto write Android applications using standard Javaprogramming language.4. Application FrameworkThe Application Framework layer provides manyhigher-level services to applications in the form ofJava classes. Application developers are allowed to make use ofthese services in their applications. 24

5. ApplicationsYou will find all the Android application at thetop layer. Examples of such applications are ContactsBooks, Browser, Games etc. 25

2.7 EMULATORS – WHAT IS ANEMULATOR /ANDROID AVD?The Android SDK includes a mobile devicesEmulator. An Emulator is a virtual mobile device that runson your computer. It allows to developed & testAndroid application without using a physicaldevices. 26


An emulator is a virtual mobile device that runs onyour computer. The emulator allows you to develop and testAndroid applications without using a physicaldevice. The Android SDK includes a virtual mobile deviceemulator that runs on your computer. AVD(Android Virtual Device) is essentially anemulator that allows Android applications to betested without installing them on a physicalandroid based device. 28


2.8 ANDROID EMULATION –CREATION AND SET UPooTo test your Android applications you will need avirtual Android device. So before we start writing ourcode, let us create an Android virtual device.Launch Android AVD Manager using Eclipse menuoptionsWindow AVD Manager which willlaunch Android AVD Manager. Use New buttonto create a new Android Virtual Device andenter the following information, before clickingCreate AVD button.30


2.9 FIRST ANDROID APPLICATIONThe first step is to create a simple AndroidApplication using Eclipse IDE. Follow the option File - New - Project andfinally select New Android Application wizardfrom the wizard list. Now name your application as HelloWorldusing the wizard window as follows: 32

This Android HelloWorld Example shows how tostart with Android Development.Example LinearLayoutxmlns:android d:layout width "fill parent"android:layout height "fill parent"android:orientation "vertical" 33

TextViewandroid:id "@ id/textView1"android:layout width "match parent"android:layout height "match parent"android:text "Hello World"android:textColor "@color/red“ / /LinearLayout 34

If you have not created AVD then first createyour AVD and then run your app.35

QUESTION BANK Define Following:1)android 2) emulator 3)ADT 4) Android SDK 5) OHAExplain main features of Android.List Android environment setup software.What is an Emulator / Android AVD?Write full form of OHA and AVD.Define ADT. Write steps for installation of AndroidDevelopment Tools (ADT) Plug-in.Draw android OS framework.Explain libraries and android runtime environment.Write steps for Creation of an Android Application.36

free of cost. 3 . W HY A NDROID? 4 . H ISTORY OF A NDROID . To install Eclipse IDE, download the latest Eclipse binaries from . Virtual Machine which is a kind of Java Virtual Machine