You are on page 1of 30

Android

Application Development
Android Basics

Credit goes to Google!


Few reasons to go MAD…

• Smart Phones
– Internet access anywhere
– Social networking
• Millions of mobile users
• Open standards
Introduction to Android
• Open software platform for mobile
development
• A complete stack – OS, Middleware,
Applications
• An Open Handset Alliance (OHA) project
• Powered by Linux operating system
• Fast application development in Java
• Open source under the Apache 2 license
Linux Kernel
Linux Kernel
• 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.
Libraries
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.
Android 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.
Application Framework

• API interface
• Activity manager – manages application
life cycle.
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.
Applications

• Built in and user apps


• Can replace built in apps
• 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 Building Blocks
• Activity
• IntentReceiver
• Service
• ContentProvider
Activities
• Typically correspond to one UI screen
• An activity is usually a single screen that the user sees on the device at one
time.
• An application typically has multiple activities, and the user flips back and
forth among them. As such, activities are the most visible part of your
application
• But, they can:
– Be faceless
– Be in a floating window
– Return a value
An activity is implemented as a subclass of Activity class as follows −
public class MainActivity extends Activity {}
Intents
• Intents are messages that are sent among the major building
blocks.
• They trigger an activity to start up, tell a service to start or
stop, or are simply broadcasts.
• Intents are asynchronous, meaning the code that sends them
doesn’t have to wait for them to be completed.
• An intent could be explicit or implicit. In an explicit intent, the
sender clearly spells out which specific component should be
on the receiving end.
Intents
• In an implicit intent, the sender specifies the type of receiver.
For example, your activity could send an intent saying it
simply wants someone to open up a web page.

• In that case, any application that is capable of opening a web


page could “compete” to complete this action.

• When you have competing applications, the system will ask


you which one you’d like to use to complete a given action.
You can also set an app as the default. 
Intents

shows how intents may be used to “jump” between various activities, in the
same application or in another app altogether.
IntentReceivers
• Components that respond to broadcast
‘Intents’
• Way to respond to external notification or
alarms
• Apps can invent and broadcast their own
Intent
Intents
• Think of Intents as a verb and object; a
description of what you want done
– E.g. VIEW, CALL, PLAY etc..
• System matches Intent with Activity that
can best provide the service
• Activities and IntentReceivers describe
what Intents they can service
Intents
Home System picks best
component for that action Photo
Gallery
Contacts

“Pick photo”
GMail

Client component makes a


Chat request for a specific
action
Blogger
Blogger
New components can use
existing functionality
Services
• Faceless components that run in the background
– E.g. music player, network download etc…
• Services run in the background and don’t have any user
interface components.
• They can perform the same actions as activities, but
without any user interface. Services are useful for
actions that we want to perform for a while, regardless of
what is on the screen.
• For example, you might want your music player to play
music even as you are flipping between other
applications.
Content Providers
• Enables sharing of data across
applications
– E.g. address book, photo gallery
• Content providers are interfaces for
sharing data between applications.
• By default, Android runs each application
in its own sandbox so that all data that
belongs to an application is totally isolated
from other applications on the system.
Content Provider
• 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. 
• Figure illustrates how the Contacts app uses Contacts
Provider, a totally separate application, to retrieve data about
users’ contacts. The Contacts app itself doesn’t have any
contacts data, and Contacts Provider doesn’t have any user
interface.
Broadcast Receiver
• Broadcast Receivers simply respond to broadcast messages from other
applications or from the system.

• For example, applications can also initiate broadcasts to let other


applications know that some data has been downloaded to the device and is
available for them to use, so this is broadcast receiver who will intercept this
communication and will initiate appropriate action.

• A broadcast receiver is implemented as a subclass


of BroadcastReceiver class and each message is broadcaster as
an Intent object.
Additional Components
• There are additional components which will be used in the construction of above
mentioned entities, their logic, and wiring between them. These components are

• Fragments
Represents a portion of user interface in an Activity.

• Views
UI elements that are drawn on-screen including buttons, lists forms etc.

• Layouts

View hierarchies that control screen format and appearance of the views

• Resources
External elements, such as strings, constants and drawable pictures.
Views
Views

You might also like