CIT 5104 Lesson 1 Andoid Devt
CIT 5104 Lesson 1 Andoid Devt
Android
Architecture
For Mobile App
Development
04/21/25 1
Android - Architecture
• Android architecture is a software stack of
components to support a mobile device
needs.
04/21/25 2
Android –
Architecture(cont.)
04/21/25 3
Applications
• The top layer of android architecture is
Applications.
• The native and third party applications like
contacts, email, music, gallery, clock, games,
etc. whatever we will built those will be installed
on this layer only.
04/21/25 4
Application Framework
• The Application Framework provides the
classes used to create an Android
applications.
04/21/25 5
Application
Framework(cont._
• Provides the services through which we
can create the particular class and make
that class helpful for the Applications
creation.
04/21/25 8
Platform Libraries(cont.)
• Media library for playing and recording
an audio and video formats
• The Surface manager library to
provide a display management
• SGL and OpenGL Graphics libraries
for 2D and 3D graphics
• SQLite is for database support and
FreeType for font support
• Web-Kit for web browser support and
SSL for Internet security.
04/21/25 9
Linux kernel
• Linux Kernel is a bottom layer and heart of
the android architecture.
• It manage all the drivers such as display
drivers, camera drivers, Bluetooth drivers,
audio drivers, memory drivers, etc. which are
mainly required for the android device during
the runtime.
• The Linux Kernel will provides an abstraction
layer between the device hardware and the
remainder of the stack.
• It is responsible for memory management,
power management, device management,
resource access, etc.
04/21/25 10
Android - Application
Components
• Application components are the essential
building blocks of an Android application.
• These components are loosely coupled by
the application manifest file
AndroidManifest.xml that describes
each component of the application and
how they interact.
• There are following four main components
that can be used within an Android
application
04/21/25 11
Android - Application
Components(cont.)
S.No
Components & Description
Activities
1 They dictate the UI and handle the user interaction to
the smart phone screen.
Services
2 They handle background processing associated with
an application.
Broadcast Receivers
3 They handle communication between Android OS and
applications.
Content Providers
4
They handle data and database management issues.
04/21/25 12
Activities
• An activity represents a single screen with a user interface,in-
short Activity performs actions on the screen.
• For example, an email application might have one activity that
shows a list of new emails, another activity to compose an email,
and another activity for reading emails.
04/21/25 13
Services
• A service is a component that runs in the
background to perform long-running operations.
• For example, a service might play music in the
background while the user is in a different
application, or it might fetch data over the network
without blocking user interaction with an activity.
04/21/25 14
Broadcast Receivers
• 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.
2 Views: UI elements that are drawn on-screen including buttons, lists forms etc.
3 Layouts: View hierarchies that control screen format and appearance of the views.
04/21/25 17
Anatomy of Android Application
• Before you run your app, you should be aware of a
few directories and files in the Android project −
04/21/25 18
Anatomy of Android
Application(cont.)
Sr.N Folder, File & Description
o.
Java
This contains the .java source files for your
project.
1 By default, it includes
an MainActivity.java source file having an
activity class that runs when your app is
launched using the app icon.
res/drawable-hdpi
2 This is a directory for drawable objects that are
designed for high-density screens.
04/21/25
res/layout 19
Java
1
This contains the .java source files for your project. By default, it includes
an MainActivity.java source file having an activity class that runs when
your app is launched using the app icon.
res/drawable-hdpi
2 This is a directory for drawable objects that are designed for high-density
screens.
3
res/layout
This is a directory for files that define your app's user interface.
res/values
4 This is a directory for other various XML files that contain a collection of
resources, such as strings and colours definitions.
AndroidManifest.xml
5 This is the manifest file which describes the fundamental characteristics
of the app and defines each of its components.
Build.gradle
6
This is an auto generated file which contains compileSdkVersion,
buildToolsVersion, applicationId, minSdkVersion, targetSdkVersion,
versionCode and versionName
04/21/25 20
The Main Activity File
• The main activity code is a Java file
MainActivity.java.
04/21/25 21
The Main Activity
File(cont.)
• package com.example.helloworld;
• import android.support.v7.app.AppCompatActivity;
• import android.os.Bundle;
• public class MainActivity extends AppCompatActivity {
• @Override
• protected void onCreate(Bundle savedInstanceState) {
• super.onCreate(savedInstanceState);
• setContentView(R.layout.activity_main);
• }
Here, R.layout.activity_main refers to
• } the activity_main.xml file located in
the res/layout folder.
The onCreate() method is one of many
methods that are figured when an activity is
loaded
04/21/25 22
The Manifest File
• Whatever component you develop as a part of
your application, you must declare all its
components in a manifest.xml which resides
at the root of the application project directory.
<resources>
<string name="app_name">HelloWorld</string>
<string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string>
<string name="title_activity_main">MainActivity</string>
</resources>
04/21/25 24
The Layout File
The activity_main.xml is a layout file available in res/layout
directory, that is referenced by your application when
building its interface.
You will modify this file very frequently to change the layout
of your application.
04/21/25 25
The Layout File
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="@dimen/padding_medium"
android:text="@string/hello_world"
tools:context=".MainActivity" />
</RelativeLayout>
04/21/25 26
Running the Application
Let's try to run our Hello
World! application we just
created.
I assume you had created
your AVD while doing
environment set-up.
To run the app from
Android studio, open one of
your project's activity files
and click Run icon from the
tool bar.
04/21/25 28