CH 1
CH 1
CH 1
• Open Source: Android is open source, meaning that the source code is
available for developers to modify and improve. This has led to a large
and active community of developers who contribute to the platform.
• Customizable User Interface: Android allows for a high degree of
customization. Users can personalize their home screens with widgets,
shortcuts, and apps. Manufacturers can also customize the operating
system to differentiate their devices.
• Google Play Store: Android provides access to the Google Play Store,
which is a vast marketplace for apps, games, music, movies, and books.
This makes it easy for users to find and install new applications.
• Multitasking: Android supports multitasking, allowing users to run
multiple apps simultaneously and switch between them seamlessly.
Cont..
• Notifications: Android provides a unified notification system that
allows users to receive alerts from various apps in a single place,
making it easier to stay informed about important events.
• Integration with Google Services: Android devices are deeply
integrated with Google services, such as Gmail, Google Maps, Google
Drive, and Google Assistant. This provides a seamless experience for
users who rely on these services.
• Hardware Compatibility: Android runs on a wide range of devices
from various manufacturers, providing users with many options
regarding design, features, and price.
Development and Ecosystem:
• Android development is primarily done using the Java programming
language, although Kotlin has become increasingly popular due to its
modern features and interoperability with Java.
• The Android Software Development Kit (SDK) provides developers
with the tools needed to create, test, and deploy applications.
• The ecosystem around Android is vast, including various development
tools, libraries, and frameworks that simplify and enhance the
development process.
• The Android Studio IDE is the official integrated development
environment for Android development, providing robust tools for
coding, debugging, and performance analysis.
Market Presence:
src The 'src' stands for Source Code. It contains the Java
Source files.
res The 'res' stands for Resource file. It can store resource files such as pictures,
XML files, etc. It contains some additional folders such as Drawable, Layout
and Values.
anim: It is used for XML files that are compiled into animation objects.
color: It is used for XML files that describe colors.
drawable: It is used to store various graphics files. In Android project
structure,
there are three types of drawable folders,
1. drawable-mdpi
2. drawable-hdpi
3. drawable-ldpi
The above drawable folders are required in order to adapt to different screen
resolutions.
layout: It is used for placing the XML layout files, which defines how various
Android objects such as textbox, buttons, etc. are organized on the screen.
menu: It is used for defining the XML files in the application menu.
raw: The 'raw' stands for Raw Asset Files. These files are referenced from the
application using a resource identifier in the R class.
For example, good place for media is MP3 or Ogg files.
values: It is used for XML files which stores various string values, such as
titles, labels, etc.
xml: It is used for configuring the application components.
Folder Name Description
AndroidManifest.xml This file indicates the Android definition file. This file contains the
information about the Android application such as minimum Android
version, permission to access Android device capabilities such as
Internet access permission, phone permission etc.
default.properties This file contains the project settings, such as build the target. Do not
edit this file manually. It should be maintained in a Source Revision
Control System.
Proguard.cfg This file defines how ProGuard optimizes and makes your code unclear.
MainLayout.xml This file describes the layout of the page. So all the components such
as textboxes, labels, radio buttons, etc. are displaying on the
application screen.
Activity class The application occupies the entire device screen which needs at least
one class inherits from the Activity class. OnCreate() method initiates
the application and loads the layout page.
Android UI Architecture
• Android UI Architecture Android UI architecture is a fundamental aspect of developing
Android applications, involving several key components like the application context,
intents, and the activity lifecycle.
• Understanding these components is crucial for building robust and efficient Android
applications.
• 1. Application Context :
• The application context in Android refers to the environment in which the application is
running. It provides access to resources, services, and application-level operations.
• The application context is primarily used for: Accessing application resources (e.g., strings,
images).
• Launching application-level services. Registering and unregistering broadcast receivers.
• Starting activities.
• The application context is accessible throughout the application and is retrieved using the
getApplicationContext() method.
• It is essential for tasks that need a context tied to the application's lifecycle rather than a
particular activity or component.
2. Intent
• Intents are messaging objects used to request actions from other components
of the application or system. They facilitate communication between different
components (such as activities, services, and broadcast receivers) and can be
used to:
• Start an activity.
• Start a service.
• Deliver a broadcast.
• There are two types of intents:
• Explicit Intent: Specifies the component to start by name (e.g., launching a
specific activity within the same application).
• Implicit Intent: Does not specify a component. The system resolves which
component to start based on the intent's action, data, and category (e.g.,
opening a web page in a browser).
3. Activity life cycle in android
Activity Lifecycle
• The activity lifecycle is a crucial concept in Android, describing the various states an activity can go
through during its existence. Understanding these states and handling them appropriately ensures a
smooth user experience and efficient resource management. The main lifecycle methods are:
• onCreate(): Called when the activity is first created. This is where you initialize the activity, set the
content view, and perform any setup tasks.
• onStart(): Called when the activity becomes visible to the user. It indicates that the activity is about to
become interactive.
• onResume(): Called when the activity starts interacting with the user. At this point, the activity is at the
top of the activity stack and receives user input.
• onPause(): Called when the system is about to resume another activity. This is where you should save
any persistent state and release resources that are not needed while the activity is in the paused state.
• onStop(): Called when the activity is no longer visible to the user. You should release resources that
are not needed while the activity is in the stopped state.
• onDestroy(): Called before the activity is destroyed. This is the final call before the activity is removed
from memory. You should clean up any resources that need to be released.
• onRestart(): Called when the activity is being restarted after being stopped. This usually happens when
the user navigates back to the activity.
UI Components in Android
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, World!"
android:textSize="18sp"
android:textColor="#000000" />
TextView example
Button
Buttons are interactive components that can be clicked to perform
actions.
<Button android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Me" />
CheckBox
• CheckBox: components are used to display a checkbox, which can be
checked or unchecked by the user
<CheckBox android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I agree to the terms and conditions" />
Progress Bar
• ProgressBar components indicate the progress of an operation.
• <ProgressBar android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true" />
Q&A