0% found this document useful (0 votes)
42 views

Introduction to Android Development

Safety

Uploaded by

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

Introduction to Android Development

Safety

Uploaded by

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

P a g e |1

Introduction to Android Development


The Android operating system is the largest installed base among various mobile platforms across the
globe. Hundreds of millions of mobile devices are powered by Android in more than 190 countries of
the world. It conquered around 75% of the global market share by the end of 2020, and this trend is
growing bigger every other day. 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
dominates the mobile OS industry because of the long list of features it provides. It’s user-friendly, has
huge community support, provides a greater extent of customization, and a large number of
companies build Android-compatible smartphones. As a result, the market observes a sharp increase in
the demand for developing Android mobile applications, and with that companies need smart
developers with the right skill set. At first, the purpose of Android was thought of as a mobile operating
system. However, with the advancement of code libraries and its popularity among developers of the
divergent domain, Android becomes an absolute set of software for all devices like tablets, wearables,
set-top boxes, smart TVs, notebooks, etc.

Features of Android
Android is a powerful open-source operating system that open-source provides immense features and
some of these are listed below.
P a g e |2

a. Android Open Source Project so we can customize the OS based on our requirements.
b. Android supports different types of connectivity for GSM, CDMA, Wi-Fi, Bluetooth, etc. for
telephonic conversation or data transfer.
c. Using wifi technology we can pair with other devices while playing games or using other
applications.
d. It contains multiple APIs to support location-tracking services such as GPS.
e. We can manage all data storage related activities by using the file manager.
f. It contains a wide range of media supports like AVI, MKV, FLV, MPEG4, etc. to play or record a
variety of audio/video.
g. It also supports different image formats like JPEG, PNG, GIF, BMP, MP3, etc.
h. It supports multimedia hardware control to perform playback or recording using a camera and
microphone.
i. Android has an integrated open-source WebKit layout based web browser to support User Interface
like HTML5, CSS3.
j. Android supports multi-tasking means we can run multiple applications at a time and can switch in
between them.
k. It provides support for virtual reality or 2D/3D Graphics
P a g e |3

Android Versions
Google launched the first version of the Android platform on Nov 5, 2007. Since then, Google released
a lot of android versions such as Apple Pie, Banana Bread, Cupcake, Donut, Éclair, Froyo, Gingerbread,
Jellybeans, Kitkat, Lollipop, marshmallow, Nougat, Oreo, etc. with extra functionalities and new
features.

The following table shows the version details of android which is released by Google from 2007 to
date.

Code Name Version API level Release date

Apple Pie Android 1.0 1 September 23, 2008

Banana Bread Android 1.1 2 February 9, 2009

Cupcake Android 1.5 3 April 30, 2009

Donut Android 1.6 4 September 15, 2009

Eclair Android 2.0 – 2.1 5-7 October 26, 2009


P a g e |4

Code Name Version API level Release date

Froyo Android 2.2 – 2.2.3 8 May 20, 2010

Gingerbread Android 2.3 – 2.3.4 9-10 December 6, 2010

Honeycomb Android 3.0.x – 3.2.x 11 – 13 February 22, 2011

Ice Cream Sandwich Android 4.0 – 4.0.4 14 – 15 October 18, 2011

Jelly Bean Android 4.1 – 4.1.2 16 – 18 July 9, 2012

Kitkat Android 4.4 – 4.4.4 19 July 9, 2012

Lollipop Android 5.0 – 5.1 21 – 22 October 17, 2014

Marshmallow Android 6.0 – 6.0.1 23 October 5, 2015

Nougat Android 7.0 – 7.1 24 – 25 August 22, 2016

Oreo Android 8.0 26 August 21, 2017

Pie Android 9.0 27 August 6, 2018

Android Q Android 10.0 29 September 3, 2019

Android 11 Android 11.0 30 September 8, 2020

Programming Languages used in Developing Android Applications


1. Java
2. Kotlin
Developing the Android Application using Kotlin is preferred by Google, as Kotlin is made an official
language for Android Development, which is developed and maintained by JetBrains. Previously before
the Java is considered the official language for Android Development. Kotlin is made official for
Android Development in Google I/O 2017.
P a g e |5

Advantages of Android Development


▪ The Android is an open-source Operating system and hence possesses a vast community for
support.
▪ The design of the Android Application has guidelines from Google, which becomes easier for
developers to produce more intuitive user applications.
▪ Fragmentation gives more power to Android Applications. This means the application can run two
activities on a single screen.
▪ Releasing the Android application in the Google play store is easier when it is compared to other
platforms.
Disadvantages of Android Development
▪ Fragmentation provides a very intuitive approach for user experience but it has some drawbacks,
where the development team needs time to adjust with the various screen sizes of mobile
smartphones that are now available in the market and invoke the particular features in the
application.
▪ The Android devices might vary broadly. So the testing of the application becomes more difficult.
▪ As the development and testing consume more time, the cost of the application may increase,
depending on the application’s complexity and features.

Android Architecture
Android architecture contains different number of components to support any android device needs.
Android software contains an open-source Linux Kernel having collection of number of C/C++ libraries
which are exposed through an application framework services.
Among all the components Linux Kernel provides main functionality of operating system functions to
smartphones and Dalvik Virtual Machine (DVM) provide platform for running an android application.
The main components of android architecture are following:-
▪ Applications
▪ Application Framework
▪ Android Runtime
▪ Platform Libraries
▪ Linux Kernel
P a g e |6

Pictorial representation of android architecture with several main components and their sub
components –

Applications –
Applications is the top layer of android architecture. The pre-installed applications like home,
contacts, camera, gallery etc and third party applications downloaded from the play store like chat
applications, games etc. will be installed on this layer only.
It runs within the Android run time with the help of the classes and services provided by the
application framework.
Application framework –
Application Framework provides several important classes which are used to create an Android
application. It provides a generic abstraction for hardware access and also helps in managing the user
interface with application resources. Generally, it provides the services with the help of which we can
create a particular class and make that class helpful for the Applications creation.
It includes different types of services activity manager, notification manager, view system, package
manager etc. which are helpful for the development of our application according to the prerequisite.
P a g e |7

Application runtime –
Android Runtime environment is one of the most important part of Android. It contains components
like core libraries and the Dalvik virtual machine(DVM). Mainly, it provides the base for the
application framework and powers our application with the help of the core libraries.
Like Java Virtual Machine (JVM), Dalvik Virtual Machine (DVM) is a register-based virtual machine
and specially designed and optimized for android to ensure that a device can run multiple instances
efficiently. It depends on the layer Linux kernel for threading and low-level memory management.
The core libraries enable us to implement android applications using the standard JAVA or Kotlin
programming languages.
Platform libraries –
The Platform Libraries includes various C/C++ core libraries and Java based libraries such as Media,
Graphics, Surface Manager, OpenGL etc. to provide a support for android development.
▪ Media library provides support to play and record an audio and video formats.
▪ Surface manager responsible for managing access to the display subsystem.
▪ SGL and OpenGL both cross-language, cross-platform application program interface (API) are
used for 2D and 3D computer graphics.
▪ SQLite provides database support and FreeType provides font support.
▪ Web-Kit This open source web browser engine provides all the functionality to display web
content and to simplify page loading.
▪ SSL (Secure Sockets Layer) is security technology to establish an encrypted link between a web
server and a web browser.
Linux Kernel –
Linux Kernel is heart of the android architecture. 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.
The Linux Kernel will provide an abstraction layer between the device hardware and the other
components of android architecture. It is responsible for management of memory, power, devices
etc.
The features of Linux kernel are:
▪ Security: The Linux kernel handles the security between the application and the system.
▪ Memory Management: It efficiently handles the memory management thereby providing the
freedom to develop our apps.
▪ Process Management: It manages the process well, allocates resources to processes whenever
they need them.
▪ Network Stack: It effectively handles the network communication.
▪ Driver Model: It ensures that the application works properly on the device and hardware
manufacturers responsible for building their drivers into the Linux build.
P a g e |8

Components of an Android Application


There are some necessary building blocks that an Android application consists of. These loosely
coupled components are bound by the application manifest file which contains the description of each
component and how they interact. The manifest file also contains the app’s metadata, its hardware
configuration, and platform requirements, external libraries, and required permissions.
There are the following main components of an android app:

1. Activities
Activities are said to be the presentation layer of our applications. The UI of our application is built
around one or more extensions of the Activity class. By using Fragments and Views, activities set the
layout and display the output and also respond to the user’s actions. An activity is implemented as a
subclass of class Activity.
• Java

public class MainActivity extends Activity {


}

To read more, refer to the article: Introduction to Activities in Android

2. Services
Services are like invisible workers of our app. These components run at the backend, updating your
data sources and Activities, triggering Notification, and also broadcast Intents. They also perform
some tasks when applications are not active. A service can be used as a subclass of class Service:
• Java

public class ServiceName extends Service {


}

To read more, refer to the article: Services in Android with Example

3. Content Providers
It is used to manage and persist the application data also typically interacts with the SQL database.
They are also responsible for sharing the data beyond the application boundaries. The Content
Providers of a particular application can be configured to allow access from other applications, and the
Content Providers exposed by other applications can also be configured. A content provider should be
a sub-class of the class ContentProvider.

• Java

public class contentProviderName extends ContentProvider {


P a g e |9

public void onCreate(){}


}

To read more, refer to the article: Content Providers in Android with Example

4. Broadcast Receivers
They are known to be intent listeners as they enable your application to listen to the Intents that satisfy
the matching criteria specified by us. Broadcast Receivers make our application react to any received
Intent thereby making them perfect for creating event-driven applications.
To read more, refer to the article: Broadcast Receiver in Android With Example

5. Intents
It is a powerful inter-application message-passing framework. They are extensively used throughout
Android. Intents can be used to start and stop Activities and Services, to broadcast messages system-
wide or to an explicit Activity, Service or Broadcast Receiver or to request action be performed on a
particular piece of data.
To read more, refer to the article: Intent and Intent Filters

6. Widgets
These are the small visual application components that you can find on the home screen of the devices.
They are a special variation of Broadcast Receivers that allow us to create dynamic, interactive
application components for users to embed on their Home Screen.

7. Notifications
Notifications are the application alerts that are used to draw the user’s attention to some particular
app event without stealing focus or interrupting the current activity of the user. They are generally
used to grab user’s attention when the application is not visible or active, particularly from within a
Service or Broadcast Receiver. Examples: E-mail popups, Messenger popups, etc.
P a g e | 10

Introduction to Activities in Android


Activity class is one of the very important parts of the Android component. Any app, don’t matter
how much small it is (in terms of code and scalability), it has at least one Activity class. Unlike most
of the programming languages, in which the main() method is the entry point for that program or
application to start its execution, the android operating system initiates the code in an Activity
instance by invoking specific callback methods that correspond to specific stages of its lifecycle. So
it can be said that An activity is the entry point for interacting with the user. Every activity contains
the layout, which has a user interface to interact with the user. As we know that every activity
contains a layout associated with it, so it can be said that activity class is the gateway, through
which a user can interact programmatically with UI. Layout for a particular activity is set with the
help of setContentView(). setContentView() is a function that takes View as a parameter. The
view parameter basically contains the layout file for that activity. The following images indicate
that activity_main is the layout file of MainActivity.
In the case of Java:

In the case of Kotlin:

While activities are often presented to the user as the full-screen window, Multiwindow mode, or
Picture in Picture mode, here are two methods almost all subclasses of Activity will implement:
1. onCreate()
2. onPause()
1. onCreate() Method
Syntax:
protected void onCreate(Bundle savedInstanceState)
▪ onCreate(Bundle) method is the place, where the user initializes the activity. This method is
called when the activity is starting. This is the method that is used to initialize most of the
P a g e | 11

things in the android app. onCreate() method takes savedInstanceState as the parameter,
which the object of type Bundle, i.e Bundle Object which contains the previously saved data of
the activity. If the activity is newly created then the bundle won’t be saving any data of the
activity and would contain the null value.
▪ onCreate() method calls the setContentView() method to set the view corresponding to the
activity. By default in any android application, setContentView point to activity_main.xml file,
which is the layout file corresponding to MainActivity. The onCreate method uses
the findViewById() method so that the user can interact programmatically with the widgets in
android and then customize them according to need.
Bundle: If the activity is being re-initialized or restarted after previously being closed, then this
Bundle contains the data it most recently supplied in
onSaveInstanceState(Bundle). onSaveInstanceState() method is the method that is called to save
the data just before our activity is killed.

2. onPause() Method
Syntax:
protected void onPause()
This method is called as part of the activity lifecycle when the user no longer actively interacts with
the activity, but it is still visible on the screen. Let’s suppose the user is running two apps
simultaneously on a mobile phone, i.e when activity B is launched in front of activity A, so activity A
will go in the onPause() state, and activity B would go in the onStart() state of the activity lifecycle.
One important point to be remembered is that for any activity to be accessed by system, ie android
here, that activity must be declared in a manifest file. The manifest file is an XML file included in
the application and default known as AndroidManifest.xml.

Declaring Activity in Manifest File


Open the app folder, and then open the subfolder manifest, and then open
the AndroidManifest.xml file.

You might also like