You are on page 1of 38

Unit 1

Overview of Android
Content
 Introduction to Android
 Android System with Architecture
 The Android Application Components
 Android manifest file
 Downloading and Installing Android
 Platforms / Versions
 Setup Android Environment
 SDK
 AVD
 Developing and Executing the first Android Application
Introduction to Android
 Android is an open source mobile platform which consists of 3 things:
 Operating System (Linux Kernel)
 Middleware
 Android / key Application
 Android is an open source, Linux-based software stack created for a wide array of devices
and form factors.
 It supports devices like mobile phones and other devices, such as tablets, watch, TV, &
auto.
 The company named Open Handset Alliance developed Android for the first time that is
based on the modified version of the Linux kernel and other open-source software.
 Google sponsored the project at initial stages and in the year 2005, it acquired the whole
company.
 In September 2008, the first Android-powered device launched in the market.
 Android also provides a marketplace (Play Store) to distribute apps.
 It conquered around 75% of the global market share by the end of 2020.
Basic Android Architecture

Android Application

Application Frameworks
Middleware

Android Runtime

Native Libraries JAVA Core Libraries

DVM (Dalvik VM)

Android OS (Linux Kernel)


Android System with Architecture
Android System with Architecture (Cont…)
 Linux Kernel:
 It manages all the available drivers such as display drivers, camera drivers,
Bluetooth drivers, audio drivers, memory drivers, etc. which are required
during the runtime.
 It is responsible for management of memory, power, devices etc.
Android System with Architecture (Cont…)
 Hardware abstraction layer (HAL):
 HAL provides standard interfaces that expose device hardware capabilities to
the higher-level Java API framework.
 consists of multiple library modules, each of which implements an interface
for a specific type of hardware component like Camera, Bluetooth etc.
 When a framework API makes a call to access device hardware, the Android
system loads the library module for that hardware component.
Android System with Architecture (Cont…)
 Android Runtime (ART) :
 It contains components like core libraries and the Dalvik virtual
machine(DVM).
 ART is written to run multiple virtual machines on low-memory devices by
executing Dalvik Executable format (DEX) files, a bytecode format designed
specifically for Android that's optimized for a minimal memory footprint.
 The core libraries enable us to implement android applications using the
standard JAVA or Kotlin programming languages.
Android System with Architecture (Cont…)
 Native C/C++ Libraries:
 Many core Android system components and services, such as ART and HAL,
are built from native code that requires native libraries written in C and C++.
 The Android platform provides Java framework APIs to expose the
functionality of some of these native libraries to apps.
 For example, you can access OpenGL ES through the Android framework’s
Java OpenGL API to add support for drawing and manipulating 2D and 3D graphics in
your app.
 If you are developing an app that requires C or C++ code, you can use the
Android NDK (Native Development Kit) to access some of these
native platform libraries directly from your native code.
Android System with Architecture (Cont…)
 Java API Framework:
 The entire feature-set of the Android OS is available to you through APIs
written in the Java language.
 These APIs form the building blocks you need to create Android apps by
simplifying the reuse of core, modular system components and services,
which include the following:
 A rich and extensible view system you can use to build an app’s UI, including lists,
grids, text boxes, buttons, and even an embeddable web browser
 A resource manager, providing access to non-code resources such as localized strings,
graphics, and layout files
 A notification manager that enables all apps to display custom alerts in the status bar
 An activity manager that manages the lifecycle of apps and provides a common
navigation back stack.
 Content providers that enable apps to access data from other apps, such as the
Contacts app, or to share their own data
Android System with Architecture (Cont…)
 System Apps :
 Android comes with a set of core apps for email, SMS messaging, calendars,
internet browsing, contacts, and more.
 System app is simply an app placed under ‘/system/app‘ folder on an
Android device which is a read-only folder.
 Android device users do not have access to this partition. Hence, users cannot
directly install or uninstall apps to/from it.
 Apps such as camera, settings, messages, Google Play Store, etc.
 The system apps function both as apps for users and to provide key
capabilities that developers can access from their own app.
 For example, if you want your app to deliver SMS messages, you don't need
to build that functionality yourself. You can instead invoke whichever SMS
app is already installed to deliver a message to the recipient you specify.
DVM
 The Dalvik Virtual Machine (DVM) is an android virtual machine optimized for mobile devices.
 It optimizes the virtual machine for memory, battery life and performance.
 Each Android application runs in its own process, with its own instance of the Dalvik VM.
 Dalvik has been written such that a device can run multiple VMs efficiently.
 Register-based virtual machine
 Executing the Dalvik Executable (.dex) format
 .dex format is optimized for minimal memory footprint.
 Compilation
 Relying on the Linux Kernel for: Threading & other Low-level memory management
 The Dex compiler converts the class files into the .dex file that run on the Dalvik VM.
 Multiple class files are converted into one dex file.
 The javac tool compiles the java source file into the class file.
 The dx tool takes all the class files of your application and generates a single .dex file.
 It is a platform-specific tool.
 The Android Assets Packaging Tool (aapt) handles the packaging Process
DVM
Building Blocks

 The building blocks are components that you use as an developer to build
Android apps.
 Main building blocks of android are
 Activities
 An activity is usually a single screen that the user sees on the device at one time.
 public class MainActivity extends Activity{

}
 Intents
 Intents are messages that are sent among the major building blocks.
Building Blocks

 Services
 Servicesrun in the background and don’t have any user interface
components.
 Same as Activity
 For example,
 A service might play music in the background while the user is in a different
application,
 It might fetch data over the network without blocking user interaction with an
activity.
 A service is implemented as a subclass of Service class as follows −
 public class MyService extends Service {

}
Building Blocks
Content Providers
 Content providers are interfaces for sharing data between applications.
 The role of the content provider is like a central repository in which data of the applications
are stored, and it facilitates other applications to securely access and modifies that data
based on the user requirements.
 For example,
 Contacts Provider is a content provider that exposes
all user contact data to various applications.
 Settings Provider exposes system settings to various
applications, including the built-in Settings
application.
 Media Store is responsible for storing and sharing
various media, such as photos and music, across
various applications.
Building Blocks
Content Providers

 public class MyContentProvider extend ContentProvider{


public void onCreate(){
}
}
Building Blocks

 Broadcast Receivers
 Broadcast receivers are Android’s implementation of a system-
wide publish/subscribe mechanism, or more precisely, an Observer
pattern.
 For example, when an SMS arrives, a call comes in, the battery runs
low, or the system gets booted, all those events are broadcasted, and
any number of receivers could be triggered by them.
 Broadcast receivers themselves do not have any visual representation,
nor are they actively running in memory. But when triggered, they get
to execute some code, such as starting an activity, a service, or
something else.
Building Blocks

 Broadcast Receivers
public class MyReceiver extends BroadcastReceiver{
public void onReceiver(context,intent){
}
}
Building Blocks

 Application Context
 Above components are used to make an application.& They live inside the same
application context.
 Application context refers to the application environment and the process within
which all its components are running.
 It allows applications to share the data and resources between various building
blocks.
 An application context gets created whenever the first component of this
application is started up.
 Application context lives as long as your application is alive.
 Using following methods we can obtain a reference to the context
 Context.getApplicationContext()
 Activity.getApplication().
Android Platforms
 The Android platform is a platform for mobile devices that uses a modified
Linux kernel.
 The Android Platform was introduced by the Open Handset Alliance in
November of 2007.
 Most applications that run on the Android platform are written in the Java
programming language.
 To create an application for the platform, a developer requires the Android
SDK, which includes tools and APIs.
Android Versions
Android Versions
Name Version Number Release Date API Level
Cupcake 1.5 April 27, 2009 3
Donut 1.6 September 15, 2009 4
Eclair 2.0 – 2.1 October 26, 2009 5–7
Froyo 2.2 – 2.2.3 May 20, 2010 8
Gingerbread 2.3 – 2.3.7 December 6, 2010 9 – 10
Honeycomb 3.0 – 3.2.6 February 22, 2011 11 – 13
Ice Cream Sandwich 4.0 – 4.0.4 October 18, 2011 14 – 15
Jelly Bean 4.1 – 4.3.1 July 9, 2012 16 – 18
KitKat 4.4 – 4.4.4 October 31, 2013 19 – 20
Lollipop 5.0 – 5.1.1 November 12, 2014 21 – 22
Marshmallow 6.0 – 6.0.1 October 5, 2015 23
Nougat 7.0 – 7.1.2 August 22, 2016 24 – 25
Oreo 8.0 – 8.1 August 21, 2017 26 – 27
Pie 9 August 6, 2018 28
Android 10 10 September 3, 2019 29
Android 11 11 September 8, 2020 30
Android 12 12-12.1 October 4, 2021 31-32
Android 13 13 August 15, 2022 33
Android Setup Environment
 you can start your Android application development on either
 Mac OS X 10.5.8 or later version with Intel chip.
 Microsoft Windows XP or later version.
 Linux including GNU C Library 2.7 or later.
 Java JDK5 or later version
 You can download the latest version of Java JDK from Oracle's Java site
Java SE Downloads.
 You will find instructions for installing JDK in downloaded files, follow the given
instructions to install and configure the setup.
 Finally set PATH and JAVA_HOME environment variable to refer to the directory
that contains java and javac.
 Android Studio
 You can download the latest version of Android Studio from Developer’s site.
Android SDK
 Android SDK stands for Android Software Development Kit which
is developed by Google for Android Platform.
 Android SDK is a collection of libraries and Software Development
tools that are essential for Developing Android Applications.
 It is compatible with all operating systems such as Windows, Linux,
macOS, etc.
Android SDK
 Components of Android SDK
 SDK Tools
 Android SDK Tools
 Android SDK Build-Tools
 Android SDK Platform-tools
 Android Emulator
 SDK Platforms
 SDK Update Sites
SDK Tools
 Below are the SDK developer tools:
 Android SDK Build tool
 Android Emulator
 Android SDK Platform-tools
 Android SDK Tools
Android SDK Tools
 It contains the complete set of Debugging and Development tools for
android.

Android SDK Build Tools


 Android SDK Build-Tools is a component of the Android SDK
required for building Android apps.
 It's installed in the <sdk>/build-tools/ directory.
 The main functions of Android SDK Build tools are built, debug, run
and test Android applications.
 While downloading or updating Android in our System, one must
ensure that its latest version is download in SDK Components.
Android SDK Platform Tools
 Android SDK Platform-tools is helpful when we are working on
Project and they will show the error messages at the same time.
 It is specifically used for testing.
 It includes:
 Android Debug Bridge (ADB), is a command-line tool that helps to
communicate with the device. It allows us to perform an action such as
Installing App and Debugging App etc.
 Fastboot allows you to flash a device with a new system image.
 Systrace tools help to collect and inspect timing information. It is very
crucial for App Debugging.
Android Emulator
 The Android Emulator simulates Android devices on your computer so that you
can test your application on a variety of devices and Android API levels without
needing to have each physical device.
 Advantages:
 Flexibility: In addition to being able to simulate a variety of devices and Android API
levels, the emulator comes with predefined configurations for various Android phone,
tablet, Wear OS, and Android TV devices.
 High fidelity: The emulator provides almost all the capabilities of a real Android device.
You can simulate incoming phone calls and text messages, specify the location of the
device, simulate different network speeds, simulate rotation and other hardware sensors,
access the Google Play Store, and much more.
 Speed: Testing your app on the emulator is in some ways faster and easier than doing so
on a physical device. For example, you can transfer data faster to the emulator than to a
device connected over USB.
 Each instance of the Android Emulator uses an Android virtual device (AVD) to specify the
Android version and hardware characteristics of the simulated device.
Android Emulator
 Android Virtual Device (AVD):
 An Android Virtual Device (AVD) is a configuration that defines the characteristics of an Android phone,
tablet, Wear OS, Android TV, or Automotive OS device that you want to simulate in the Android
Emulator.
 An AVD contains a hardware profile, system image, storage area, skin, and other properties.
 Hardware profile
 The hardware profile defines the characteristics of a device as shipped from the factory.
 The Device Manager comes pre-loaded with certain hardware profiles, such as Pixel devices, and you can define or
customize the hardware profiles as needed.
 System images
 A system image labeled with Google APIs includes access to Google Play services.
 Storage area
 The AVD has a dedicated storage area on your development machine. It stores the device user data, such as installed
apps and settings, as well as an emulated SD card. If needed, you can use the Device Manager to wipe user data so
the device has the same data as if it were new.
 Skin
 An emulator skin specifies the appearance of a device. The Device Manager provides some predefined skins. You can
also define your own or use skins provided by third parties.
 AVD and app features
 Just as with a real device, for apps to use certain features defined in an AVD, such as the camera, it must have the
corresponding setting in the app manifest.
Android Emulator
 Android Virtual Device (AVD):
 The Device Manager is a tool you can launch from Android Studio that helps
you create and manage AVDs.
 To open the Device Manager, do one of the following:
 From the Android Studio Welcome screen, select More Actions > Virtual Device
Manager.
 After opening a project, select View > Tool Windows > Device Manager from the
main menu bar, and then click Create device.
Create an AVD
 Open the Device Manager.
 Click Create Device. The Select Hardware window appears.
Create an AVD
 Select a hardware profile, then click Next.
 If you don't see the hardware profile you want, you can create or import a
hardware profile, as described in other sections on this page.
 The System Image window appears
Create an AVD
 Select the system image for a particular API level, and then click Next.
 The Verify Configuration window appears.
Create an AVD
 Change the AVD properties as needed, and then click Finish.
Click Show Advanced Settings to show more settings, such as the
skin.
 The new AVD appears in the Virtual tab of the Device Manager and
the target device menu.
SDK Platforms
 New SDK platform tools are available to download in SDK Platform
tools. Each SDK platform tools package consists of android platform
and sources pertaining to an API level by default.
 For Each Android Software, one SDK platform is available as shown
below:
References
 https://developer.android.com/
 https://www.oreilly.com/library/view/learning-android/9781449304881/c
h04.html
 https://www.javatpoint.com/android-tutorial
 https://www.geeksforgeeks.org/introduction-to-android-development/?ref
=lbp

You might also like