0% found this document useful (0 votes)
8 views28 pages

CIT 5104 Lesson 1 Andoid Devt

The document provides an overview of Android architecture for mobile app development, detailing its five sections and four main layers. It explains the roles of various components such as Applications, Application Framework, Android Runtime, Platform Libraries, and the Linux Kernel. Additionally, it describes application components like Activities, Services, Broadcast Receivers, and Content Providers, along with the structure of an Android application including the manifest, layout, and resource files.

Uploaded by

oliverwekesa337
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views28 pages

CIT 5104 Lesson 1 Andoid Devt

The document provides an overview of Android architecture for mobile app development, detailing its five sections and four main layers. It explains the roles of various components such as Applications, Application Framework, Android Runtime, Platform Libraries, and the Linux Kernel. Additionally, it describes application components like Activities, Services, Broadcast Receivers, and Content Providers, along with the structure of an Android application including the manifest, layout, and resource files.

Uploaded by

oliverwekesa337
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 28

Lesson 1

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.

• Android operating system is a stack of


software components which is roughly divided
into five sections and four main layers as
shown below in the architecture diagram.

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.

• The application layer runs within the Android run


time using the classes and services made
available from the application framework.

04/21/25 4
Application Framework
• The Application Framework provides the
classes used to create an Android
applications.

• Provides a generic abstraction for


hardware access and manages the user
interface and application resources.

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.

• The application framework includes


services like telephony service, location
services, notification manager, NFC
service, view system, etc. which we can
use for application development as per
our requirements.
04/21/25 6
Android Runtime
• Android Runtime environment is an important part of
Android rather than an internal part and it contains a
components like core libraries and the Dalvik virtual
machine. The Android run time is the engine that powers
our applications along with the libraries and it forms the
basis for the application framework.

• Dalvik Virtual Machine (DVM) is a register-based virtual


machine like Java Virtual Machine (JVM). It is specially
designed and optimized for android to ensure that a device
can run multiple instances efficiently. It relies on the Linux
kernel for threading and low-level memory management.

• The core libraries in android runtime will enable us to


implement an android applications using standard JAVA
programming language.
04/21/25 7
Platform Libraries
• The Platform Libraries includes various
C/C++ core libraries and Java based
libraries such as SSL, libc, Graphics,
SQLite, Webkit, Media, Surface Manger,
OpenGL etc. to provide a support for
android development.

• Following are the summary details of


some core android libraries available for
android development.

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.

• If an application has more than one activity, then one of them


should be marked as the activity that is presented when the
application is launched.

• An activity is implemented as a subclass of Activity class as


follows −

• public class MainActivity extends Activity {


•}

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.

• A service is implemented as a subclass of Service


class as follows −

• public class MyService extends Service {


•}

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.

• A broadcast receiver is implemented as a subclass of


Broadcast Receiver class and each message is broadcaster
as an Intent object.

• public class MyReceiver extends BroadcastReceiver {


• public void onReceive(context,intent){}
•}
04/21/25 15
Content Providers
• A content provider component supplies data from one
application to others on request. Such requests are
handled by the methods of the ContentResolver class.
The data may be stored in the file system, the database
or somewhere else entirely.

• A content provider is implemented as a subclass of


ContentProvider class and must implement a standard
set of APIs that enable other applications to perform
transactions.

• public class MyContentProvider extends


ContentProvider {
• public void onCreate(){}
•}
04/21/25 16
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 −
S.No Components & Description

1 Fragments: Represents a portion of user interface in an Activity.

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.

4 Intents: Messages wiring components together.

5 Resources: External elements, such as strings, constants and drawable pictures.

6 Manifest: Configuration file for the application.

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

3 This is a directory for files that define your app's


Anatomy of Android
Sr.No.
Application(cont.) Folder, File & Description

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.

• This is the actual application file which


ultimately gets converted to a Dalvik
executable and runs your application.

• Following is the default code generated by


the application wizard for Hello World!
application −

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.

• This file works as an interface between


Android OS and your application, so if you do
not declare your component in this file, then it
will not be considered by the OS.

• For example, a default manifest file will look


like as following file −
04/21/25 23
The Strings File
The strings.xml file is located in the res/values folder and it contains all the text
that your application uses. For example, the names of buttons, labels, default text,
and similar types of strings go into this file. This file is responsible for their textual
content. For example, a default strings file will look like as following file −

<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.

 For your "Hello World!" application, this file will have


following content related to default layout

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.

 Android studio installs the


app on your AVD and starts
it and if everything is fine
with
04/21/25 your set-up and 27

application, it will display


THE END
Thank you!

04/21/25 28

You might also like