0% found this document useful (0 votes)
11 views31 pages

Android App Development Essentials

The document outlines the course IS 238: Mobile Application Development, focusing on Android app development. It covers key concepts such as the structure of an Android project, components like Activities, Services, BroadcastReceivers, and ContentProviders, as well as the importance of the Android Manifest file. Additionally, it discusses the roles of various components and how they interact within an Android application.

Uploaded by

shaikielyn16
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)
11 views31 pages

Android App Development Essentials

The document outlines the course IS 238: Mobile Application Development, focusing on Android app development. It covers key concepts such as the structure of an Android project, components like Activities, Services, BroadcastReceivers, and ContentProviders, as well as the importance of the Android Manifest file. Additionally, it discusses the roles of various components and how they interact within an Android application.

Uploaded by

shaikielyn16
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

IS 238 : Mobile Application Development

(12 credits)

Lecture :
Instructor : Dr. Kennedy Thursday 12:00 – 14:00
E-mail: kenfactz@[Link] Room: D01 (LUHANGA HALL)

Practical:
Friday 14:00 – 16:00
1
Unit II: Android basic concepts

2
Lecture 2: Android Application Overview

3
What Makes Up an Android Project

 Android application is software that can freely run on any Android


device and performs several tasks.
 An Android Application is built with any of the following
programming languages:
 Java
 Kotlin
 C++
 All these three languages are supported by Android Studio IDE.
 An Android app, is made up of loosely coupled components that
communicate to each other using a message-passing mechanism

4
What Makes Up an Android Project

 Figure 1 below shows the logical structure of an app.


Figure 1:logical structure of an app

5
What Makes Up an Android Project

 An APK is the file format for distributing and installing Android apps.
It contains all the elements an Android app needs, such as:
 Resources: Images, sounds, and other assets used by the app.
 Manifest File: Contains information about the app, including its
permissions, components, and required libraries.
 DEX Files: Contain the compiled code of the app.
 Libraries: Any libraries the app uses, such as Google Play
Services.
 How APKs Work:
 Installation: Download an APK file and install it manually on
mobile devices. The Android system verifies the APK's
signature and then installs it.
6
What Makes Up an Android Project

 Execution: To launch an app, the Android system extracts the


necessary components from the APK and loads them into
memory.
 Extraction: When an app is launching, the Android system
extracts the necessary components from the APK and loads
them into memory.
 Execution: The Android Runtime (ART) executes the app's
code, allowing it to interact with the device's hardware and
software.

7
What Makes Up an Android Project

 Distribution: APKs are commonly distributed through the Google


Play Store or directly downloaded from websites.
 Sideloading: Installing APKs outside the Google Play Store is called
sideloading. It requires enabling "Unknown Sources" in your device
settings.
 Signing: APKs need to be signed with a digital certificate to ensure
authenticity and security.

8
Android App Components

 Android application components are the basic building blocks of


Android apps. They provide the functionality and structure that
make up an Android app.
 An Android application comprises four essential components and
some additional components.
1) Activities
2) Services
3) BroadcastReceivers
4) ContentProviders
 Each component serves a distinct purpose and has a distinct
lifecycle that defines how the component is created and destroyed.
 They define a path for both the user and the system to how they
9 can start or leave an application.
Android App Components

1: Activities
In Android, Activity represents a single screen with a user interface
(UI), and it will act as an entry point for the user to interact with an app.
 An Activity is where to put together things that the user can see. For
example, an email app might have an activity for displaying a list of
emails, an activity for viewing a single email, and an activity for
composing a new email..
In Figure 1 inside the Activity, there are Views and Fragments.
 Views are classes that draw content to the screen; some examples of
View objects are Buttons and TextViews.
 A Fragment is similar to an Activity in a way that it’s also a composition
unit but a smaller one. Like Activities, they also hold View objects.

10
Android App Components

1: Activities
In Android, Activity represents a single screen with a user interface
(UI), and it will act as an entry point for the user to interact with an app.
 An Activity is where to put together things that the user can see. For
example, an email app might have an activity for displaying a list of
emails, an activity for viewing a single email, and an activity for
composing a new email..
In Figure 1 inside the Activity, there are Views and Fragments.
 Views are classes that draw content to the screen; some examples of
View objects are Buttons and TextViews.
 A Fragment is similar to an Activity in a way that it’s also a composition
unit but a smaller one. Like Activities, they also hold View objects.

11
Android App Components

1: Activities
An Android Activity is a key component of an Android app that
represents a single screen with a user interface.
Each activity is a standalone module of functionality that provides a
space for the app's user to interact with the app's content.
 For instance, an email app might have one Activity to show a list
of emails, another to compose an email, and another to read an
email.
An activity is implemented as a subclass of class
AppCompactActivity.
public class MainActivity extends AppCompatActivity {

12 }
Android App Components

2: Services
Android Service is a component that runs in the background to
perform long-running operations without a user interface.
It's ideal for tasks that don't require direct user interaction, such as
playing music, downloading files, or syncing data with a remote server.
Services can run even when the app is not in the foreground, and
they can communicate with activities and other components.
A service can be used as a subclass of class Service:

public class ServiceName extends Service


{
}

13
Android App Components

3: BroadcastReceivers
Broadcast receivers are components that receive broadcast events
from the Android system.
Broadcast events are notifications that are sent by the system or
other apps to indicate that something has happened, such as a
change in the network connection state or a new SMS message being
received.
Usually, broadcast receivers help to notify users of any process or
application.
They can notify the user either through notification, status bar, or
even the user’s application(if active).
Broadcast receivers can be used to react to these events and update

14 the app's UI or perform other actions.


Android App Components

3: BroadcastReceivers
A sample use case for this might
 Low battery reminders - Whenever your device has insufficient
charge left, your device notifies you to keep charged or on
battery saver mode
 Alarm application. Whenever you keep an alarm, you leave that
application or, in simple terms, close that application. Still, at a
particular time, you receive the notification.
A receiver is implemented by extending a BroadcastReceiver class

public class myReceiver extends BroadcastReceiver


{
15 }
Android App Components

4: ContentProviders
Components that provide access to an application’s data are content
providers.
Content providers are components that manage and share data
between different apps.
They provide a unified way to access and modify data, regardless of
where the data is stored.
The Content Providers can share the app data that is stored in the
file system, SQLite database, on the web or any other storage location
that an app can access.
Through the content provider, other apps can query or even modify
the data
16
Android App Components

4: ContentProviders
For example, android provides a Content Provider
([Link]) to manage contact information, by using
proper permissions, any app can query the content provider to perform
read and write operations on contact information.
A content provider should be a sub-class of the class
ContentProvider.

public class contentProviderName extends ContentProvider
{
public void onCreate(){}
}

17
Additional Components of Android App

 In Android, there are several other additional components of an


Android app.
 They are used to build the relationship between the above
components (Activities, Intents, Content Providers, Services and
Broadcast Receivers) to implement application logic; these include
1) Intents
 Intents are a powerful component in any Android application.
 It allows various applications and various activities to communicate with
each other.
 It carries information about which activity shall be going next or which
activity to stop or destroy.
 It is used to transfer data from one activity to another.
 Intent objects are also used to send or receive broadcasts generated
18 by the system.
Additional Components of Android App

2) Widgets
 Widgets are a designing and customisation component.
 Whenever you see your device’s home screen, you can find several
widgets like clock, weather, etc.
 These widgets allow you to change the appearance of your home
screen and even allow easy access to some often required stuff.

H/W
Find and read types of widgets which are very often seen on any device:

19
Additional Components of Android App

3) Views
 Views are the components that are often used for designing and event-
handling purposes.
 Thus, views are part of both designing and coding. Using the views, we
can describe how an element will behave or interact with the user.
 There are several views in Android.
 The most common of them are as follows:
 EditText
 ImageView,
 TextView,
 Button
 Radio Button
 Nested Scroll View
20
Additional Components of Android App

4) Notifications
 Notifications are 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 the 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.

21
Additional Components of Android App

5) Fragments
 Fragments allow you to provide multiple functionalities by creating a
single activity.
 Using fragments, you can do several tasks on the same activity
itself.
 Fragments are reusable and can be used for various activities if
required.
 The fragment is made of Views and View Pager.
 For example, In WhatsApp, you can see that there is an activity
that contains chat, update, and call as fragments. Using the same
activity, you can even chat, keep status or call someone.

22
Additional Components of Android App

6) XML file
 XML file makes up the layout for any Android application.
 Using XML, we can create various designs or layouts for our
application.
 XML even allows us to transfer data from the database to our
layout file.

7) Resources
 Resources store several things in Android.
 Whether you need a particular font style, image, colours,
animations, or strings, all of these are stored in resources.
 Resources also allow you to put vector images in your android
23 application.
Additional Components of Android App

8) APK Build
 After the development is done, you can combine your code,
resources, and files in one one-unit called APK(Android Application
Package).
 This package can be installed on your device by the Package
Manager, and then the user can use that application.

24
Android Manifest File

 It is a manifest written in XML.


 The [Link] file is a crucial component of every
Android app
 It is a configuration file that provides essential information about an
app to the Android system.
 This file is located in the root directory of the Android project.
 Key Roles of the Manifest File:
1) Package Name: Defines a unique identifier for an app.
2) Version Information: Specify the version code and version name of
an app.
3) Permissions: Declares the permissions an app needs to access
system features like the camera, storage, or network.
25
Android Manifest File

4) Application Component Declarations:


 Activities: Defines the activities that make up your app's user
interface.
 Services: Declares background services that run independently of
any user interface.
 Broadcast Receivers: Defines components that respond to
system-wide broadcast messages.
 Content Providers: Declares components that manage and share
structured data.
5) Intent Filters: Specifies the intents that an activity, service, or
broadcast receiver can respond to.
6) Minimum SDK Version: Sets the minimum Android API level
required for an app to run.
26 7) Hardware and Software Features: Declares the hardware and
software features an app requires.
Android Manifest File

 The manifest is a busy place; there are a lot of things to keep an


eye on.
 Most of its entries are automatically taken care of by the creation
wizards of Android Studio IDE.
 One of the few occasions to interact with it is probably when
there is a need to add permissions to an app.
 The manifest is also important for Google Play when it displays an
app on the store.
 The app won’t appear on devices that do not meet the
requirements stipulated in your manifest file.

27
Application Entry Point

 An app typically interacts with a user, and it does so using Activity


components.
 App usually has, at least, these three things.
1) An Activity class that the user sees first as soon as the app launches
2) A layout file for the Activity class which contains all the UI definitions
like text views, buttons, and so on
3) The AndroidManifest file, which ties all the project resources and
components together
 When an application is launched, the Android Runtime creates an
Intent object and inspects the manifest file.
 It’s looking for a specific value of the intent-filter node (in the xml
file).
28
Application Entry Point

 The runtime is trying to see if the application has a defined entry


point, something like a main function
 L1: Excerpt from [Link]

 If the application has more than one Activity, there will be several
activity nodes in the manifest file, one node for each Activity
29
Application Entry Point

 The first line of the definition has an attribute called android:name;


this points to the class name of an Activity.
 In this example, the name of the class is “MainActivity.”
 The second line declares the intent-filter, when you see something
like [Link], on the intent-filter node, it means
the Activity is the entry point for the application.
 When the app launches, this is the Activity that the user will see.

30
END OF LECTURE

31

You might also like