Android Module 1 Calicut University
Android Module 1 Calicut University
MODULE ONE
www.teachics.org
The Computer Science Learning Platform.
■ History of android.
■ Android software stack.
■ Developing end user application using
Android SDK.
■ Android java packages,
■ Setting up the development environment,
Table of Contents ■ Installing android development tools(ADT),
■ Fundamental components.
■ Android virtual devices.
■ Running on real device.
■ Structure of android application.
■ Application life cycle
■ An open source and linux-based operating system and software platform for mobile computing
platform.
■ It offers a unified approach to application development for mobile devices.
■ Developed by Open Handset Alliance (OHA) led by Google.
■ “The Open Handset Alliance is a consortium of 84 firms to develop open standards for mobile devices.
Member firms include HTC, Sony, Dell, Intel, Motorola, Qualcomm, Texas Instruments, Google, Samsung
Electronics, LG Electronics, T-Mobile, Sprint Corporation, Nvidia, and Wind River Systems.”
Early History of Android
■ Android Inc. was founded in October 2003 by Andy Rubin, Rich Miner, Nick Sears, and Chris White.
■ Android Inc. was acquired by Google in 2005.
■ In 2007, google formed Open Handset Alliance which included phone makers like HTC and Motorola,
chip manufacturers such as Qualcomm and Texas Instruments, and carriers including T-Mobile.
■ The first beta version of Android 1.0 for developers was launched on Nov 5, 2007 (Android’s Birthday).
■ In September 2008, first Android smartphone T-Mobile G1 (HTC Dream) was announced.
Android Versions
Android Versions
■ 1.0 (2008)
● Android Market.
● Google Maps, Gmail, Contacts, etc.
● Web Browser.
● Camera Support.
■ 1.1 (2009)
● Show and Hide numeric keyboard in caller application.
■ 1.5 : Cupcake (2009)
● Bluetooth.
● Soft Keyboard with text prediction.
● Record/ watch Videos.
■ 1.6 : Donut (2009)
● Navigation.
● Gesture framework.
Android Versions
■ 2.0 - 2.1 : Eclair (2009-10)
● HTML.
● Live Wallpaper.
■ 2.2 : Froyo (2010)
● JIT implementation.
● USB tethering.
● Application installation to external storage.
● Animated GIFs.
■ 2.3 - 2.3.7 : Ginger Bread (2010-11)
● Video call support.
● NFC support.
● Social networking features.
● Google Talk.
Android Versions
■ 3.0 - 3.2.6 : Honey Comb (2011-12)
● Multicore support.
● Customizable home screen.
● Recent applications viewing.
● Automatic updates.
■ 4.1 - 4.3 : Jelly Bean (2012-13)
● Google Now.
● Voice search.
● Show estimated time remaining in active downloads
● Dialpad auto complete.
■ 4.4 - 4.4.4 : Kitkat (2013-14)
● Screen recording.
● Enhanced notification access.
Android Versions
■ 5.0 - 5.1.1 : Lollipop (2014-15)
● Material design.
● Lock protection if lost.
● HD video call.
■ 6.0 - 6.0.1 : Marshmallow (2015)
● Type-C USB support.
● Fingerprint authentication support.
● MIDI support.
● Permission dashboard.
■ 7.0 - 7.1.2 : Nougat (2016-17)
● Better multitasking.
● PIP.
● Battery usage alerts.
Android Versions
■ 8.0 - 8.1 : Oreo (2017)
● PIP with resizable windows.
● Instant Apps.
■ 9.0 : Pie (2015)
● Digital wellbeing.
● Adaptive brightness.
■ 10 : Android 10 (2019)
● Dark theme.
● Sound amplifier.
● Live caption.
■ 11 : Android 11 (2020)
● Smart reply.
● Built in screen recording.
● Device controls.
Android Software Stack
■ A software stack is a set of software systems or components needed to create complete
platform such that no additional software is needed to support applications.
■ Android OS is a stack of software components which is divided into 5 sections and 4 main
layers
● Linux kernel.
● Native libraries,
● Android Runtime.
● Application Framework.
● Applications.
Android Software Stack
Android Software Stack
Linux Kernel
■ ‘kernel’ means ‘core’.
■ It is the heart of android architecture that exists at the root of android architecture.
■ Linux kernel is the base of the software layers upon which all other layers of the android are
built.
■ Users are not allowed to directly interact with this layer.
■ All the essential hardware drivers are located in Linux Kernel.
■ Linux Kernel can also act as an abstraction layer between hardware and software layers.
■ Important functions of kernel in the android system:
● Hardware abstraction
● Memory management programs
● Security settings
● Power management software
● Network stack
● Device driver management
Android Software Stack
Native Libraries
■ Next to Linux Kernel layer is the Android’s Native Libraries.
■ They provide capabilities for android’s core features. Libraries help the device to handle
different types of data.
■ Some of the important native libraries:
● Surface Manager - manages access to the display subsystem and 2D and 3D graphic
layers from multiple applications .
● Media Framework - for playing and recording audio and video formats.
● SQLite - is an android database engine which stores data.
● WebKit - is a browser engine that displays HTML content.
● OpenGL - renders 2D or 3D graphic contents on the screen.
● FreeType - for font support
● Libc - C runtime library
Android Software Stack
Android Runtime
■ This is the 3rd section of the architecture and available on the second layer from the bottom.
■ In android runtime, there are core libraries and DVM (Dalvik Virtual Machine) which is
responsible to run android application.
■ DVM is like JVM but it is optimized for mobile devices.
■ It consumes less memory and provides fast performance.
■ DVM takes the generated java class files and combines them into one or more .dex files.
■ Goal of DVM is to find every possible ways to optimize the JVM for space, performance and
battery life.
Android Software Stack
Android Framework
■ On the top of Native libraries and android runtime, there is android framework.
■ Android framework layer which is written in Java includes Android API's such as UI (User
Interface), telephony, resources, locations, Content Providers (data) and package
managers.
■ It provides a lot of classes and interfaces for android application development.
■ Some of the basic tools with which applications are built:
● Activity Manager : Activity life cycles of applications are managed.
● Content Providers : data sharing among applications are managed.
● Telephony Manager : manages the location via GPS or base station receiver.
● Resource Manager : various types of resources used in applications are managed.
Android Emulator
■ The Android SDK includes a virtual mobile device emulator that runs on the computer.
■ The emulator lets you prototype, develop and test Android applications without using a
physical device.
■ Emulator can used to run, debug, and test applications. You will not even need the real
device for 90 percent of your application development.
■ The full-featured Android emulator mimics most of the device features, some limitations
regarding USB connections, camera and video capture, head- phones, battery
simulation, and Bluetooth.
■ The Android emulator accomplishes its work through an open source “processor
emulator” technology called QEMU developed by Fabrice Bellard.
Android UI
■ Android uses a UI framework that resembles other desktop-based, full-featured UI
frame-works, but it’s more modern and more asynchronous in nature.
■ Android is almost a fourth-generation UI framework
● Traditional C-based Microsoft Windows API -the first generation
● C++ based MFC (Microsoft Foundation Classes) - second generation.
● The Java-based Swing UI framework -third generation,
● The Android UI, JavaFX, Microsoft Silverlight, and Mozilla XML
User Interface Language (XUL) - fourth-generation UI framework
■ UI is declarative and independently themed.
■ Programming in the Android UI involves declaring the interface in XML files.
● load these XML view definitions as windows in your UI application.
● Even menus in application are loaded from XML files
■ Screens or windows in Android are referred to as activities,
● comprise multiple views that a user needs in order to accomplish a logical unit of action.
● Views are Android’s basic UI building blocks, and it can be combined to form composite views
called view groups.
Android Java Packages
■ android.app: implements application model for android
■ android.app.admin: Provides device administration features at the system level
■ android.accounts: provides classes to manage accounts such as google,facebook
■ android.animation: to apply animation for different objects,animation classes and
methods are included
■ android.app.backup:Contains the backup and restore functionality available to
applications.
■ android.content:Manages access to a central repository of data
■ android.database:Contains classes to explore data returned through a content provider.
■ android.database.sqlite: Contains the SQLite database management classes that an
application would use to manage its own private database.
■ android.graphics: Provides low level graphics tools such as canvases, color filters, points,
and rectangles that let you handle drawing to the screen directly.
Android Java Packages
■ android.location: contains classes for managing location.
■ android.media: supports video streaming and play audio and video files
■ android.os: provides operating system services through java such as IPC,file server
management etc.
■ android.text: provides text processing classes
■ android.view: contains classes menu,view,viewgroups and a series of listeners
■ android.webkit:classes representing web browser
■ android.widget: contains all of the UI controls(list,grid,image)
Setting Up The Development Environment
■ Downloading and installing JDK.
● Set the JAVA_HOME environment variable to point to the JDK install folder.
■ Download the Eclipse IDE
■ Downloading the Android SDK.
● The SDK contains - base tools & packages.
● The tools part includes an emulator and a setup utility to install the packages.
● The packages are the files specific to a particular version of Android (platform) or a particular
add-on to a platform.
■ Updating path environmental variable
■ Installing Android Development Tools (ADT)
● Eclipse plug-in that helps to build Android applications.
■ From Eclipse, you can launch the SDK Manager.
Choose Window ➤ Android SDK Manager.
Fundamental Components
■ Views
● Everything you see is a view.
● UI elements that form the basic building blocks of UI.
● Also used as container of views.
● Button, Label, Text fIeld, etc.
■ Activity
● A UI concept that usually represent a single screen in your application.
● Contains one or more views.
● Helps the user to do something.
■ Fragment
● Like sub activities- an activity can display one or more fragments on the screen at same time.
■ Intent
● Defines an intention to do something.
● Initiated by applications or system.
● Broadcast a message, start a service, launch an activity, dial a phne number, display a list of
contacts.
Fundamental Components
■ Content Provider
● Mechanism for sharing data among applications.
● Share data without exposing underlying storage, structure and implementation.
■ Services
● Background processes.
● Local service - components that are only accessible application starting the service.
● Remote service - services that are meant to be accessed by other application running on same
device.
■ Android Manifest.xml
● Defines the contents and behaviour of your application.
● List activities, services, along with permissions and features.
Android Virtual Devices
■ AVD is a device configuration that is run with the android emulator
■ It is an emulator configuration that allows developers to test the application by simulating
the real device capabilities.
■ It works with the emulator to provide a virtual device-specific environment in which to
install and run Android apps.
■ In computing, an emulator is hardware or software that enables one computer
system(host) to behave like another computing system(guest).
■ Emulator enables the host system to run software or use peripheral devices designed for
the guest system.
■ The AVD Manager is a tool you can use to create update,delete, repair, and manage
Android virtual devices (AVDs), which define device configurations for the Android
Emulator.
■ To open the AVD Manager
Select Tools →AVD Manager or Click AVD Manager icon in the toolbar.
■ Click create Virtual Device button.
■ In the select hardware screen select a hardware profile, and then click Next.
■ In the System Image screen select the system image for a particular API level, and then
click Next .
■ Verify the configuration settings and then finish.
■ To run an app in Android Studio, you can click the green arrow in the menu bars at the
top.
■ Or you can click the Run menu, then select Run.
Running on Real Device
■ Active State
● When an Activity is in active state, it means it is active and running.
● It is visible to the user and the user is able to interact with it.
● Process state is foreground
● Android Runtime treats the Activity in this state with the highest priority and never tries to
kill it.
■ Paused State
● An activity being in this state means that the user can still see the Activity in the
background such as behind a transparent window or a dialog box ie. it is partially visible.
● The user cannot interact with the Activity until he/she is done with the current view.
● Process state is visible
● Android Runtime usually does not kill an Activity in this state but may do so in an extreme
case of resource crunch.
Android Application Life Cycle - States
■ Stopped State
● When a new Activity is started on top of the current one or when a user hits the Home
key, the activity is brought to Stopped state.
● The activity in this state is invisible, but it is not destroyed.
● Process state is background
● Android Runtime may kill such an Activity in case of resource crunch.
■ Destroyed State
● When a user hits a Back key or Android Runtime decides to reclaim the memory allocated
to an Activity i.e in the paused or stopped state, It goes into the Destroyed state.
● The Activity is out of the memory and it is invisible to the user.
Life Cycle Methods
■ onCreate() - Whenever an Activity starts running, the first method to get executed is oncreate().
This method is executed only once during the lifetime. The initialization of any instance variables
in the Activity can be done in this method.
■ onStart() - After onCreate() method, the onStart() method is executed. During the execution of
onStart() method, the Activity is not yet rendered on screen but is about to become visible to the
user. In this method, we can perform any operation related to UI components.
■ onResume() - When the Activity finally gets rendered on the screen, onResume() method is
invoked. At this point, the Activity is in the active state and is interacting with the user.
■ onPause() - If the activity loses its focus and is only partially visible to the user, it enters the
paused state. During this transition, the onPause() method is invoked. We may commit database
transactions or perform light-weight processing before the Activity goes to the background.
■ onStop() - From the active state, if we hit the Home key, the Activity goes to the background
and the Home Screen Of the device is made visible. During this event, the Activity enters the
stopped state- Both onPause() and onStop() methods are executed.
Life Cycle Methods
■ onDestroy() - When an activity is destroyed by a user or Android system, onDestroy() function
is called.
■ When the Activity comes back to focus from the paused state, onResume() is invoked.
■ When we reopen any app(after pressing Home key), Activity now transits from stopped state to
the active state.
■ Thus, onStart() and onResume() methods are invoked.
■ onCreate() method is not called, as it is executed only once during the Activity life-cycle.
■ To destroy the Activity on the screen, we can hit the Back key.
■ This moves the Activity into the destroyed state.
■ During this event, onPause(), onStop() and onDestroy() methods are invoked.
■ Whenever we change the orientation of the screen i.e from portrait to landscape or vice-versa,
lifecycle methods start from the start i.e from onCreate() method.
Thank You.
43
Picture Credits
■ Android introduction image - android.com
■ Android logo GIF - Android Authority
■ Cupcake - Photo by Vojtech Okenka from Pexels
■ Donut - Photo by cottonbro from Pexels
■ Eclair - Photo by C Technical from Pexels
■ Frozen Yogurt - Photo by Nela Kovac from Pexels
■ Ginger Bread - Photo by KoolShooters from Pexels
■ Honeycomb - Photo by Archana GS from Pexels
■ Icecream - Photo by Valeria Boltneva from Pexels
■ Jelly - Photo by Graham Walker from Pexels
■ Kitkat - Tumblr Kitkat.com
■ Lollipop - Photo by Karolina Grabowska from Pexels
■ Marshmallow - Photo by Conny Querales Araujo de Bonaguro from Pexels
■ Nougat - Image by Ulrike Leone from Pixabay
■ Oreo - Photo by ABHISHEK HAJARE from Pexels
■ Pie - Photo by Asya Vlasova from Pexels