0% found this document useful (0 votes)
9 views22 pages

Android Architecture and Components Explained

Uploaded by

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

Android Architecture and Components Explained

Uploaded by

rojojadhav
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

U1 Q1. EXPLAIN ANDROID ARCHITECTURE WITH A DIAGRAM.

1)Android architecture is divided into four main layers, where each layer provides services to the layer above
it.

2)Android Architecture is a layered model divided into four main parts. The first layer is the Linux Kernel,
which handles low-level system tasks such as process management, memory management, security, and
hardware drivers like camera, display, and Bluetooth.

3)The next layer is the Libraries and Android Runtime, where the native libraries such as SQLite, OpenGL ES,
WebKit, and the Media Framework provide essential features for graphics, databases, web browsing, and
media.

4) The Android Runtime (ART) executes applications by converting code into machine code and efficiently
managing memory.

5)Above this is the Application Framework, which provides important APIs and system services needed for
app development.

6)It includes the Activity Manager for managing screens, the Window Manager for handling the user interface,
Content Providers for data sharing, the Package Manager for managing applications, and the Resource Manager
for handling layouts and images.

7)At the top of the architecture is the Applications layer, which contains both built-in and user-installed apps
such as Phone, Contacts, WhatsApp, and Instagram. Each layer depends on the layer below it, making Android
a well-structured and efficient operating system.

Diagram
U1 QUE2) Intent and Intent Filters

Intent

1. Intent is a messaging object used in Android to request an action from another app component.

2. It helps different components like Activities, Services, and Broadcast Receivers communicate with each
other.

3. Intents can carry action information and data, allowing Android to pass information between screens
or apps.

4. Types of Intents:

o Explicit Intent:

▪ Clearly specifies the target component.

▪ Used to open a specific activity within the same app.

▪ Example: Opening SecondActivity from MainActivity.

o Implicit Intent:

▪ Does not specify a component; only describes the required action.

▪ Android selects the appropriate app to perform the task.

▪ Example: Using ACTION_VIEW to open a webpage in a browser.

5. Intents allow Android to perform tasks like opening screens, sharing data, sending SMS, accessing
camera, and more.

Intent Filters

6. Intent Filter is a declaration in the AndroidManifest file that specifies which types of intents a
component can respond to.

7. It tells the system what actions, categories, and data types an activity, service, or broadcast receiver
can handle.

8. Intent filters are required mainly to receive implicit intents, because the system needs to match the
intent with a suitable component.

9. Example: An activity with an intent filter containing ACTION_SEND and data type "text/plain" will
appear in the sharing menu when the user shares text from another app.

10. Intent filters allow apps to become visible to the system and to other apps by advertising their
capabilities.
U1 QUE3) EXPLAIN ACTIVITY AND ITS LIFE CYCLE.

1. An Activity in Android represents a single screen with a user interface.


2. It is one of the most important components used to interact with the user.
3. Every app contains one or more activities for different screens.
4. Activities handle user input, display UI elements, and manage app interaction.
5. The MainActivity is usually the entry point of the application.
Activity Life Cycle
6. The Activity Life Cycle is the sequence of states an activity goes through from creation to
destruction.
7. onCreate() is called when the activity is first created and is used to initialize UI, variables,
and components.
8. onStart() is called when the activity becomes visible to the user but is not interactive.
9. onResume() is called when the activity becomes interactive and the user can start using
it.
[Link]() is called when the activity loses focus, such as when another activity partially
covers it.
[Link]() is called when the activity becomes completely invisible to the user.
[Link]() is called when the activity is coming back to the foreground after being
stopped.
[Link]() is called when the activity is being destroyed and removed from memory.
[Link] life cycle ensures that the app uses resources efficiently and handles state changes
properly.
[Link] override these methods to manage tasks like saving data, releasing
resources, and updating UI.
U1 Q4) Service and Its Life Cycle

Service
1. A Service in Android is a background component that performs long-running tasks
without a user interface.
2. It continues working even if the user switches to another application.
3. Services are used for tasks such as playing music, downloading files, uploading data, or
running background processes.
4. Unlike activities, services do not interact directly with the user.
5. Services can run in the foreground, background, or as bound services, depending on the
requirement.
Types of Services
6. Started Service: Begins when an app calls startService() or startForegroundService() and
works independently in the background.
7. Bound Service: Allows other components to bind using bindService() and interact with
the service until it is unbound.
Service Life Cycle Methods
8. onCreate() is called when the service is first created; used to initialize resources.
9. onStartCommand() is called each time the service is started using startService(); handles
the main background task.
[Link]() is called when a component binds to a bound service; returns an interface for
communication.
[Link]() is called when all clients disconnect from a bound service.
[Link]() is called if a new client binds after the service was previously unbound.
[Link]() is called when the service is stopped or destroyed, and it is used to release
resources.
U1 QUE5) Fragment and Its Life Cycle.

Fragment
1. A Fragment is a reusable portion of the user interface inside an activity.
2. It represents a part of the UI or behavior, like a mini-activity that lives inside an activity.
3. Fragments help in creating flexible and modular UI, especially for tablets and multi-pane
layouts.
4. A fragment must always be hosted inside an activity; it cannot run independently.
5. Fragments can be added, removed, or replaced at runtime using the FragmentManager.
6. They help in reusing UI components and improve the app's structure and maintainability.

Fragment Life Cycle


7. onAttach() is called when the fragment is attached to its host activity.
8. onCreate() initializes essential components of the fragment (similar to activity onCreate).
9. onCreateView() is used to create and return the UI layout of the fragment.
[Link]() is called when the activity’s onCreate() is completed; fragment gets
access to activity data.
[Link]() makes the fragment visible to the user.
[Link]() allows the fragment to become interactive and ready for user input.
[Link]() is called when the fragment loses focus but is still partially visible.
[Link]() makes the fragment completely invisible to the user.
[Link]() destroys the fragment’s UI view but the fragment object may still exist.
[Link]() is called to clean up final resources.
[Link]() is called when the fragment is removed from the activity.
U2 QUE1) UI Components in Android (Explanation + Examples)

➔ UI Components (User Interface Components) are the visible elements that make up the screen of an
Android application. They allow the user to interact with the app by clicking, typing, scrolling, selecting,
etc. UI components are placed inside layouts and are defined using XML or created using Java/Kotlin in
code.

UI Components in Android

1. TextView – TextView is a user interface element used to display text to the user. It is
static in nature, meaning the user cannot edit it, and is commonly used for headings,
labels, or instructions within an app.
2. EditText – EditText is a UI component that allows the user to enter and edit text. It is an
editable text field, often used for forms, login screens, or search bars.
3. Button – A Button is an interactive component that performs an action when clicked by
the user. Buttons are used to submit forms, navigate between screens, or trigger any
specific functionality in the app.
4. ImageView – ImageView is a component that displays images in the app. It can be used
to show logos, icons, pictures, or any graphical content within the interface.
5. CheckBox – CheckBox allows users to select one or more options from a set. It is
commonly used when multiple selections are allowed, like agreeing to terms or selecting
preferences.
6. RadioButton – RadioButton is a selection component used when only one choice can be
selected from a group. It is often used in forms, surveys, or multiple-choice questions.
7. Spinner – Spinner is a dropdown component that enables the user to choose one option
from a list. It is useful for selecting categories, countries, or other predefined options.
8. ListView / RecyclerView – These components display a scrollable list of items. ListView
is simpler, while RecyclerView is more flexible and efficient, often used to display data
like contacts, messages, or product lists.
9. ProgressBar – ProgressBar visually indicates the progress of a task. It can show either a
determinate progress (completion percentage) or indeterminate progress (loading or
waiting).
[Link] / ToggleButton – Switch or ToggleButton is used to turn a setting ON or OFF. It is
commonly used in settings screens to enable or disable features.
U2 QUE2) Event Handling in Android
Event Handling in Android is the process through which an application responds to user
actions on the user interface. These actions, called events, can be interactions like clicking a
button, touching the screen, entering text, scrolling a list, or pressing a key. Event handling is
essential to make Android apps interactive, dynamic, and responsive.
In Android, almost every UI component can generate events. For example, a Button
generates a click event, a CheckBox generates a checked/unchecked event, and an EditText
generates text change events. The system detects these events and notifies the application
so it can respond appropriately.
Android uses a listener-based event handling mechanism. A listener is an interface that
contains callback methods which get executed when an event occurs. For instance,
OnClickListener listens for click events, and its onClick() method is automatically called when
the user clicks the associated UI component. Similarly, OnTouchListener listens for touch
events, OnLongClickListener handles long press actions, and TextWatcher monitors changes
in text fields.
Example: Handling Button Click
1. Java Code
Button btnSubmit = findViewById([Link]);
[Link](new [Link]() {
@Override
public void onClick(View v) {
// Code to execute when button is clicked
[Link](getApplicationContext(), "Button Clicked", Toast.LENGTH_SHORT).show();
}});
Explanation:
• setOnClickListener() attaches a listener to the button.
• onClick() is the callback method that executes when the button is clicked.
• In this example, a Toast message is displayed on the screen when the user clicks the
button.
U2 QUE3) Drag and Drop in Android – Theory
Drag and Drop in Android is an interactive feature that allows users to move UI elements or
data from one location to another using touch gestures. It is a powerful mechanism for
making applications more interactive, intuitive, and user-friendly, especially in apps like file
managers, image galleries, games, or custom layout editors. The concept is similar to dragging
files on a computer desktop from one folder to another.
The drag and drop mechanism involves two main components: the drag source and the drop
target. The drag source is the UI element that the user wants to move, such as an image, text,
or button. The drop target is the area or element where the user intends to place the dragged
item. Both the source and target need to be defined in the app and must have appropriate
event listeners.
If you want, I can also make a concise 12-point version suitable for writing directly in exams,
keeping all key theory. Do you want me to do that?
The process of drag and drop involves two main components:
1. Drag Source – The UI element that the user wants to move.
2. Drop Target – The UI element or area where the user wants to drop the dragged item.
In Android, drag and drop is event-driven and uses a combination of listeners:
• OnLongClickListener – Starts the drag operation when the user performs a long press on
the source element.
• OnDragListener – Detects and handles drag events on the drop target.
The drag and drop operation typically follows these steps:
1. Start Dragging – The user long-presses on the drag source, initiating the drag event.
2. Dragging – The system provides visual feedback as the user moves the item across the
screen.
3. Drop – When the user releases the item over the drop target, the drop event is
triggered.
4. Handle Data Transfer – The application updates the UI or data based on the drop action.
Drag and drop improves usability and interactivity by allowing users to directly manipulate
items on the screen, making apps more intuitive and engaging.
U2 QUE4) UI LAYOUTS AND TYPES.

UI Layout in Android defines the structure and arrangement of visual elements


(UI components) on the screen. Layouts are containers that organize components
like TextView, Button, ImageView, EditText, etc. in a particular order or pattern,
determining how they appear on different screen sizes and orientations. Layouts
help create responsive and user-friendly interfaces by controlling the position,
size, and alignment of UI components.
Android provides several types of layouts, each suited for different design
requirements. The main types are:

Linear Layout: Arranges UI components in a single row or column, either


horizontally or vertically, and the orientation is controlled using the
android:orientation property, making it useful when components need to be
displayed one after another in order.
Relative Layout: Positions UI components relative to each other or relative to the
parent container, allowing alignment to the top, bottom, left, right, center, or next
to another view, making it suitable for flexible and dynamic UI designs.
Frame Layout: Holds a single child view or multiple views stacked on top of each
other, with the last added view displayed on top, commonly used for fragments or
overlaying views.
Table Layout: Organizes UI components in rows and columns using TableRow,
making it ideal for forms, structured data, or grids of information.
Grid Layout: Arranges UI components in a grid of rows and columns where
elements can span multiple rows or columns, making it suitable for dashboards,
calculators, or image galleries.
Constraint Layout: Positions UI components using constraints relative to other
views or the parent container, allowing creation of complex, flexible, and
responsive UI designs without deep view nesting.
U2 QUE5) UI Controls in Android.

1. TextView is a UI control used to display static text on the screen, providing labels,
headings, or instructions to the user.
2. EditText is a UI control that allows the user to enter and edit text, commonly used in
forms, login screens, or search fields.
3. Button is an interactive control that performs a specific action when clicked, such as
submitting a form or navigating to another screen.
4. ImageView is used to display images on the screen, including icons, logos, or pictures.
5. CheckBox allows users to select one or more options from a set of choices, useful for
multiple selections in forms or settings.
6. RadioButton allows users to select only one option from a group of choices, often used
in surveys or preference selections.
7. Spinner is a dropdown control that enables the user to select a single value from a list of
predefined options.
8. ListView is a scrollable list control that displays multiple items vertically and allows the
user to select one or more items.
9. RecyclerView is an advanced version of ListView that efficiently displays large datasets
with improved performance and flexibility.
[Link] visually indicates the progress of a task or operation, either as determinate
progress or an indeterminate loading indicator.
[Link] or ToggleButton allows users to turn a setting ON or OFF, commonly used in app
settings or preferences.
[Link] is a slider control that allows the user to select a value from a continuous range,
often used for volume or brightness adjustment.
[Link] is a control that enables users to provide ratings, typically displayed as stars
for products or content.
[Link] is a control that allows users to select a date from a calendar interface.
[Link] is a control that allows users to select a time, usually with hour and minute
fields.
U3 QUE1)EXPLAIN ANIMATION AND TYPES
Animation in Android is a visual effect applied to UI components to make the app more interactive and
engaging by changing the appearance, position, size, or transparency of elements over time.

1. Tween Animation performs smooth transitions on UI components by changing their position, size,
rotation, or transparency between two values over a specified duration.

2. Translate Animation moves a UI element from one position to another along the X and Y axes, giving
the effect of sliding across the screen.

3. Scale Animation changes the size of a UI element either by enlarging or shrinking it over a defined
duration.

4. Rotate Animation rotates a UI component around a pivot point, which can be the center or a custom
location on the element.

5. Alpha Animation changes the opacity or transparency of a UI element, making it gradually appear or
disappear.

6. Frame Animation (Drawable Animation) displays a sequence of images (frames) one after another to
create the effect of motion, similar to a flipbook or cartoon animation.

7. View Animation is applied to UI components to create movement, rotation, scaling, or fading without
affecting the actual layout bounds of the component.

8. Property Animation allows more advanced and flexible animations by changing any property of an
object over time, including color, position, size, or custom attributes.

9. ObjectAnimator is used in property animation to animate a single property of a view from a start value
to an end value smoothly.

10. AnimatorSet allows combining multiple animations together, such as moving, rotating, and fading a
component simultaneously or sequentially.

11. MotionLayout Animation is a modern animation system in Android used for complex layout
transitions, allowing interactive animations tied to gestures or screen states.

12. Animations help in improving user experience, making applications look dynamic, modern, and
intuitive.

13. Using animations effectively can guide user attention and highlight important actions in the app.

14. Overall, Android provides a variety of animation types to achieve smooth, flexible, and visually
appealing UI effects that enhance interactivity and usability.
U3 QUE2) View Animation in Android with an example:

View Animation

View Animation in Android is used to create visual effects on UI components such as moving, rotating, scaling,
or fading a view without affecting the actual layout parameters of the component. This means the view may
appear to move or change, but its position and size in the layout hierarchy remain the same. View animations
are generally defined using XML files or programmatically in Java/Kotlin and are applied to views like Button,
TextView, or ImageView. View animation includes Translate (move), Scale (resize), Rotate (rotate), and Alpha
(fade) types.

Example of View Animation (Translate Animation)

1. XML File (res/anim/[Link])

<translate xmlns:android="[Link]

android:fromXDelta="0%"

android:toXDelta="100%"

android:duration="1000"

android:repeatCount="1"

android:repeatMode="reverse"/>

2. Java Code to Apply Animation

ImageView image = findViewById([Link]);

Animation animation = [Link](this, [Link]);

[Link](animation);

Explanation:

• The image moves horizontally from its original position to 100% of its width over 1 second.

• repeatCount="1" and repeatMode="reverse" makes it move back to its original position.

• The layout position of the ImageView does not actually change; only its visual appearance moves.
U3 QUE3) Android Backup

1. Android Backup is a mechanism that allows applications to save user data and app settings to prevent
data loss when a device is reset, replaced, or upgraded.

2. It ensures that users can restore their apps and data without manually reconfiguring or re-entering
information after switching devices.

3. Android provides automatic backup services that can store data in Google Drive or other cloud storage
depending on the app’s configuration.

4. Backup can include app settings, user preferences, database files, shared preferences, and other
important files.

5. Developers can implement backup functionality using the BackupManager API to define which data
should be backed up and restored.

6. Key-value backup allows apps to store small amounts of data in key-value pairs, which is simple and
suitable for app settings or preferences.

7. Full backup allows apps to back up entire app data, including files, databases, and shared preferences,
providing a complete restore option.

8. Backup operations are typically automatic and periodic, reducing the need for user intervention while
keeping the data safe.

9. Android Backup ensures seamless user experience by restoring the app state after reinstallation or
device change.

10. Users can also manually trigger backup and restore through device settings for greater control over
their data.

11. Security is important, so backup data is often encrypted during storage and transmission to protect
user privacy.

12. Overall, Android Backup helps developers provide data reliability, continuity, and improved user
satisfaction, making apps more trustworthy.
U3 QUE2) Android Developer’s Tools

1. Developer’s Tools in Android are a set of utilities and applications that help developers
build, test, debug, and optimize Android applications efficiently.
2. Android Studio is the official IDE for Android development, providing a complete
environment for writing code, designing UI, and managing project files.
3. The SDK Manager is a tool that allows developers to download, update, and manage
different Android SDK versions, platforms, and tools required for development.
4. The AVD Manager enables developers to create and manage Android Virtual Devices
(emulators) to test apps on different device configurations without physical devices.
5. Emulators simulate Android devices on a computer, allowing developers to test app
behavior, UI, and performance across multiple screen sizes and Android versions.
6. Logcat is a powerful debugging tool that displays system messages, runtime errors, and
log outputs, helping developers identify and fix issues in the code.
7. Debugger in Android Studio allows developers to pause code execution, inspect
variables, and track the flow of the application to identify logic errors.
8. Layout Inspector is used to analyze and debug the UI hierarchy of an app in real time,
making it easier to fix layout and rendering issues.
9. Profiler Tools monitor the CPU, memory, network, and battery usage of an app, helping
developers optimize performance and resource utilization.
[Link] Tool scans the code to detect potential bugs, performance issues, and adherence
to best practices, improving app quality.
[Link] Build System automates the building, compiling, and packaging of Android
applications, handling dependencies efficiently.
[Link] (Android Debug Bridge) is a command-line tool that allows developers to
communicate with connected Android devices, install apps, and run shell commands for
debugging.
[Link] is a tool used to shrink, optimize, and obfuscate code, making the app smaller
and more secure before release.
[Link]’s tools collectively enable faster development, efficient debugging, and
better optimization, ensuring high-quality and reliable Android applications.
15.U3 QUE3) Android Internal Storage.
1. Android Internal Storage is a private storage space allocated to an app on the device, where data is
saved securely and is accessible only by that app.

2. It is used to store sensitive data, such as user preferences, login credentials, and application settings,
ensuring privacy and security.

3. Data stored in internal storage is sandboxed, meaning other apps cannot access it without explicit
permission.

4. Internal storage can store files, databases, and shared preferences used by the application for
persistent storage.

5. Files saved in internal storage are automatically deleted when the app is uninstalled, keeping the
device clean of orphaned data.

6. Developers can use methods like openFileOutput() and openFileInput() to write and read files in
internal storage.

7. The storage location is usually in the /data/data/<package_name>/files directory on the device.

8. Internal storage is fast and reliable because it resides on the device memory, making data access
quicker than external storage.

9. It is ideal for storing small to medium-sized files, such as text files, configuration files, or JSON data.

10. Data stored in internal storage is automatically private and protected, so additional encryption is
optional but can be added for extra security.

11. Android internal storage does not require any special permissions in the manifest to read or write data.

12. Internal storage is useful for saving application state and temporary data that should not be shared
with other apps or the user.

13. It ensures data integrity because files are stored directly on the device and are less prone to corruption
than external storage.

14. Developers can also use context methods like getFilesDir() to get the path to internal storage
programmatically.

15. Overall, internal storage provides a secure, private, and reliable method to store application-specific
data that is essential for app functionality.
U3 QUE4) Android Emulator in point-wise style with complete sentences, suitable for exams:

1. Android Emulator is a virtual device that simulates the Android operating system on a
computer, allowing developers to test and run applications without a physical device.
2. It replicates the functionality of an actual Android smartphone or tablet, including
screen size, resolution, memory, CPU, sensors, and network connectivity.
3. Developers can use the emulator to install, run, and debug apps in a controlled
environment.
4. The emulator is part of the Android Studio development environment and is managed
using the AVD (Android Virtual Device) Manager.
5. Using an emulator, developers can test apps on multiple device configurations like
different screen sizes, Android versions, and hardware specifications.
6. The emulator allows simulating user interactions such as touch gestures, button clicks,
keyboard input, and even device rotation.
7. It can also simulate device hardware features such as GPS location, battery levels,
network conditions, camera, and accelerometer.
8. The emulator supports running multiple virtual devices simultaneously, which helps
test apps in different environments at the same time.
9. Developers can use snapshots in the emulator to save the current state and quickly
resume testing without restarting the device.
[Link] emulator is useful for debugging and testing apps, especially for edge cases, app
behavior under different conditions, and device compatibility.
[Link] convenient, emulators are slower than real devices for certain tasks, such as
graphics-intensive apps or games.
[Link], Android Emulator provides a flexible, safe, and cost-effective solution for
testing Android applications during development.
U4 QUE1) Loading Spinner in Android
A Loading Spinner is a UI component that indicates to the user that a background operation, such as data
loading, network request, or processing, is in progress. It improves user experience by providing visual
feedback and preventing the app from appearing frozen. In Android, the Loading Spinner can be implemented
using the ProgressBar component with the indeterminate property set to true.

1. XML Layout Code

<ProgressBar

android:id="@+id/progressBar"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:indeterminate="true"

android:visibility="gone"/>

Explanation:

• android:indeterminate="true" makes the spinner rotate continuously, indicating ongoing work.

• android:visibility="gone" hides the spinner initially until it is needed.

2. Java Code to Show/Hide Spinner

ProgressBar progressBar = findViewById([Link]);

// To show spinner

[Link]([Link]);

// To hide spinner

[Link]([Link]);

Explanation:

• setVisibility([Link]) displays the spinner when a task starts.

• setVisibility([Link]) hides the spinner when the task is completed.


U5 QUE1) Sensors in Android, written in 12–15 points with one complete sentence per point, suitable for
exams:

1. Sensors in Android are hardware components that detect and measure physical properties of the
device or environment, allowing apps to respond to changes automatically.

2. They provide data about motion, orientation, environmental conditions, and device position to create
interactive and context-aware applications.

3. Android classifies sensors into two main types: hardware sensors and software sensors, depending on
whether the sensor uses physical hardware or system-based computation.

4. Hardware sensors include accelerometer, gyroscope, magnetometer, proximity sensor, light sensor, and
temperature sensor, which detect real-world phenomena.

5. Software sensors are virtual sensors like orientation, rotation vector, or step counter, which derive data
by combining hardware sensor outputs.

6. The Accelerometer measures acceleration force applied to the device in three axes, useful for motion
detection, shakes, or tilt-based controls.

7. The Gyroscope measures the rate of rotation around the device’s axes, used in gaming, navigation, and
augmented reality applications.

8. The Magnetometer (Compass) measures the magnetic field around the device, helping determine the
device’s orientation relative to Earth’s magnetic north.

9. The Proximity Sensor detects the presence of nearby objects without physical contact, commonly used
to turn off the screen during calls.

10. The Light Sensor measures ambient light intensity, enabling apps to adjust screen brightness
automatically for user comfort.

11. The Temperature and Humidity Sensors detect environmental conditions, useful in weather or health-
monitoring applications.

12. Developers access sensors through the SensorManager class, which provides methods to list, register,
and monitor sensors in real time.

13. The SensorEventListener interface is used to receive sensor data continuously and respond to changes
in sensor values.

14. Sensors enable context-aware applications, such as fitness trackers, augmented reality apps, and smart
home controls.

15. Proper use of sensors enhances user experience, interactivity, and app intelligence, making
applications responsive to the user’s environment and actions.
U5 QUE2) Session Management and Database in Android

Session Management in Android


1. Session Management in Android refers to the process of storing and
managing user-specific data during the app usage to maintain a continuous
and personalized experience.
2. It is used to remember user login states, preferences, and settings, so users
do not have to log in repeatedly.
3. Developers typically use SharedPreferences, SQLite database, or in-memory
variables to manage sessions depending on the app’s requirement.
4. SharedPreferences is commonly used to store small key-value pairs, such as
user login status, username, or theme settings.
5. Session management ensures secure handling of sensitive data, such as
tokens or authentication credentials, to prevent unauthorized access.
6. Developers can create a SessionManager class that handles login, logout, and
session persistence efficiently.
7. A session typically starts when the user logs in and ends when the user logs
out or after a specified timeout period.
8. Proper session management improves user experience, personalization, and
security of the application.
9. Persistent sessions allow the app to restore user state and preferences even
after closing or restarting the app.
10. Developers should also handle session expiration and automatic logout
for security-sensitive applications like banking or shopping apps.
U5 QUE3) Database in Android

1. Android apps often use a database to store structured data for persistent
storage and efficient retrieval.
2. SQLite is the most commonly used built-in database in Android that provides
a lightweight, relational database engine.
3. SQLite stores data in tables with rows and columns, supporting SQL queries
to insert, update, delete, and fetch data.
4. Developers interact with SQLite using classes like SQLiteOpenHelper, which
helps create and manage the database.
5. The database can store user data, app settings, records, and other
structured information for offline usage.
6. Android also supports Content Providers for sharing data between apps
while maintaining security.
7. Cursor objects are used to navigate through query results and extract data
from the database efficiently.
8. Proper database design ensures data integrity, consistency, and optimized
performance of the app.
9. For large or complex apps, developers may also use Room Persistence
Library, which is an abstraction over SQLite for easier database handling.
10. Databases combined with session management allow apps to
remember user actions, preferences, and history, enhancing the overall user
experience.
U5 QUE4) UI Patterns and Components in Android (

1. UI Patterns are standard design templates that guide how user interface elements are organized and
how users interact with the application to provide a consistent and intuitive experience.

2. They help developers create apps that are user-friendly, predictable, and easy to navigate by reusing
proven design solutions.

3. Common UI patterns include Navigation Drawer, Tab Layout, List Views, Cards, and Bottom
Navigation, each serving a specific purpose in organizing content.

4. Navigation Drawer is a sliding panel that provides access to different sections of the app without
cluttering the main screen.

5. Tab Layout allows users to switch between multiple views or sections by tapping on tabs at the top or
bottom of the screen.

6. Cards are containers that group related information visually, often used to display content like articles,
images, or products.

7. Bottom Navigation provides quick access to the main sections of an app, typically using icons and
labels at the bottom of the screen.

8. Lists and Grids are UI patterns for displaying large collections of data efficiently, allowing scrolling and
item selection.

9. UI Components are the building blocks of the app interface, such as Buttons, TextViews, ImageViews,
EditTexts, CheckBoxes, RadioButtons, Spinners, and ProgressBars.

10. Each component has specific properties and behaviors, which can be customized using XML attributes
like android:text, android:src, or android:layout_width.

11. Components can be combined with layouts and UI patterns to create structured, visually appealing,
and interactive screens.

12. Developers can use event listeners with UI components to respond to user interactions, making the
app dynamic and functional.

13. Consistency in UI patterns and components ensures that users can learn and navigate the app quickly
without confusion.

14. Modern Android apps often follow Material Design principles, which define guidelines for using
patterns and components effectively.

15. Overall, understanding UI patterns and components is essential for creating efficient, responsive, and
user-friendly applications that enhance user engagement.

You might also like