0% found this document useful (0 votes)
4 views16 pages

Android Study Guide

The document is a study guide for Android Mobile Application Development, covering key concepts such as mobile application development, basic components of Android applications, and the importance of the AndroidManifest.xml file. It explains the activity lifecycle methods, the MVC design pattern, and layout managers, along with their functions and types. Additionally, it discusses the killable states of activities and the best state for saving data.

Uploaded by

rfntc924wb
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)
4 views16 pages

Android Study Guide

The document is a study guide for Android Mobile Application Development, covering key concepts such as mobile application development, basic components of Android applications, and the importance of the AndroidManifest.xml file. It explains the activity lifecycle methods, the MVC design pattern, and layout managers, along with their functions and types. Additionally, it discusses the killable states of activities and the best state for saving data.

Uploaded by

rfntc924wb
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

Android Mobile Application Development

Study Guide • 14 Questions ‫ ﺳﺆﺍﻻ‬١٤ • ‫ﻣﺮﺷﺪ ﺍﻟﺪﺭﺍﺳﺔ‬

Page 1 | Android Mobile Application Development


Define mobile application development and state the basic components of
1 an Android application.

Definition:

Mobile application development is the process of developing software applications for mobile devices such
as smartphones and tablets.

Basic Android Components:

• Activity: A single screen visible to the user.


• Service: Performs background tasks such as playing music or downloading files.
• Broadcast Receiver: Listens for system events and responds to them.
• Content Provider: Manages and shares application data with other apps.

English ‫ﺍﻟﻌﺮﺑﻴﺔ‬

:‫ﺍﻟﺘﻌﺮﻳﻒ‬
.‫ﺗﻄﻮﻳﺮ ﺗﻄﺒﻴﻘﺎﺕ ﺍﻟﻤﻮﺑﺎﻳﻞ ﻫﻮ ﻋﻤﻠﻴﺔ ﺇﻧﺸﺎﺀ ﺑﺮﺍﻣﺞ ﻟﻸﺟﻬﺰﺓ ﺍﻟﻤﺤﻤﻮﻟﺔ ﻛﺎﻟﻬﻮﺍﺗﻒ ﺍﻟﺬﻛﻴﺔ ﻭﺍﻷﺟﻬﺰﺓ ﺍﻟﻠﻮﺣﻴﺔ‬

:‫ﺍﻟﻤﻜﻮﻧﺎﺕ ﺍﻷﺳﺎﺳﻴﺔ ﻓﻲ ﺃﻧﺪﺭﻭﻳﺪ‬


Activity (‫ ﺷﺎﺷﺔ ﻭﺍﺣﺪﺓ ﺗﻈﻬﺮ ﻟﻠﻤﺴﺘﺨﺪﻡ‬:(‫ﺍﻟﻨﺸﺎﻁ‬. •
Service (‫ ﺗﻨﻔﺬ ﻣﻬﺎﻡ ﻓﻲ ﺍﻟﺨﻠﻔﻴﺔ ﻣﺜﻞ ﺗﺸﻐﻴﻞ ﺍﻟﻤﻮﺳﻴﻘﻰ‬:(‫ﺍﻟﺨﺪﻣﺔ‬. •
Broadcast Receiver (‫ ﻳﺴﺘﻤﻊ ﻷﺣﺪﺍﺙ ﺍﻟﻨﻈﺎﻡ ﻭﻳﺴﺘﺠﻴﺐ ﻟﻬﺎ‬:(‫ﻣﺴﺘﻘﺒﻞ ﺍﻟﺒﺚ‬. •
Content Provider (‫ ﻳﺪﻳﺮ ﺑﻴﺎﻧﺎﺕ ﺍﻟﺘﻄﺒﻴﻖ ﻭﻳﺸﺎﺭﻛﻬﺎ ﻣﻊ ﺍﻟﺘﻄﺒﻴﻘﺎﺕ‬:(‫ﻣﺰﻭﺩ ﺍﻟﻤﺤﺘﻮﻯ‬. •

Page 2 | Android Mobile Application Development


2 What is [Link]? What is its importance?

[Link] is a file in the root directory of every Android application. It provides essential
information about the app to the Android system.

Importance:

• Defines the application package name (unique identifier).


• Describes app components: Activities, Services, Broadcast Receivers, Content Providers.
• Declares required permissions (Camera, Internet, etc.).
• Defines permissions needed by other applications to interact with it.
• Lists required libraries (e.g., Google Maps).
• Declares required hardware features (e.g., camera, GPS).

English ‫ﺍﻟﻌﺮﺑﻴﺔ‬

.‫ ﻳﻮﺟﺪ ﻓﻲ ﺍﻟﻤﺠﻠﺪ ﺍﻟﺮﺋﻴﺴﻲ ﻟﻜﻞ ﺗﻄﺒﻴﻖ ﺃﻧﺪﺭﻭﻳﺪ ﻭﻳﻘﺪﻡ ﻣﻌﻠﻮﻣﺎﺕ ﺃﺳﺎﺳﻴﺔ ﻟﻨﻈﺎﻡ ﺍﻟﺘﺸﻐﻴﻞ‬[Link] ‫ﻣﻠﻒ‬

:‫ﺍﻷﻫﻤﻴﺔ‬
.‫( ﻭﻫﻮ ﺍﻟﻤﻌﺮﻑ ﺍﻟﻔﺮﻳﺪ‬Package Name) ‫• ﻳﺤﺪﺩ ﺍﺳﻢ ﺣﺰﻣﺔ ﺍﻟﺘﻄﺒﻴﻖ‬
.Broadcast Receivers ‫ ﻭ‬Services ‫ ﻭ‬Activities :‫• ﻳﺼﻒ ﻣﻜﻮﻧﺎﺕ ﺍﻟﺘﻄﺒﻴﻖ‬
.‫• ﻳﻌﻠﻦ ﺍﻷﺫﻭﻧﺎﺕ ﺍﻟﻤﻄﻠﻮﺑﺔ ﻣﺜﻞ ﺍﻟﻜﺎﻣﻴﺮﺍ ﻭﺍﻹﻧﺘﺮﻧﺖ‬
.‫• ﻳﺤﺪﺩ ﺍﻷﺫﻭﻧﺎﺕ ﺍﻟﺘﻲ ﺗﺤﺘﺎﺟﻬﺎ ﺍﻟﺘﻄﺒﻴﻘﺎﺕ ﺍﻷﺧﺮﻯ ﻟﻠﺘﻔﺎﻋﻞ ﻣﻌﻪ‬
.Google Maps ‫• ﻳﺴﺮﺩ ﺍﻟﻤﻜﺘﺒﺎﺕ ﺍﻟﻤﻄﻠﻮﺑﺔ ﻣﺜﻞ‬
.GPS ‫• ﻳﺤﺪﺩ ﻣﻤﻴﺰﺍﺕ ﺍﻷﺟﻬﺰﺓ ﺍﻟﻤﻄﻠﻮﺑﺔ ﻣﺜﻞ ﺍﻟﻜﺎﻣﻴﺮﺍ ﻭ‬

Page 3 | Android Mobile Application Development


3 Describe and show by figure methods of an activity lifecycle in Android.

Method Description ■■■■■

onCreate() Called when the Activity is first created. .‫ﺗﺴﺘﺪﻋﻰ ﻋﻨﺪ ﺇﻧﺸﺎﺀ ﺍﻟﻨﺸﺎﻁ ﻷﻭﻝ ﻣﺮﺓ‬

onStart() Called when the Activity becomes visible. .‫ﺗﺴﺘﺪﻋﻰ ﻋﻨﺪ ﻇﻬﻮﺭ ﺍﻟﻨﺸﺎﻁ ﻟﻠﻤﺴﺘﺨﺪﻡ‬

onResume() Called when the Activity starts interacting with user. .‫ﺗﺴﺘﺪﻋﻰ ﻋﻨﺪ ﺑﺪﺀ ﺍﻟﺘﻔﺎﻋﻞ ﻣﻊ ﺍﻟﻤﺴﺘﺨﺪﻡ‬

onPause() Called when Activity is partially covered or unfocused. .‫ﺗﺴﺘﺪﻋﻰ ﻋﻨﺪ ﺗﻐﻄﻴﺔ ﺍﻟﻨﺸﺎﻁ ﺟﺰﺋﻴﺎ‬

onStop() Called when the Activity is no longer visible. .‫ﺗﺴﺘﺪﻋﻰ ﻋﻨﺪ ﺍﺧﺘﻔﺎﺀ ﺍﻟﻨﺸﺎﻁ ﺗﻤﺎﻣﺎ‬

onRestart() Called after stopped Activity is about to restart. .‫ﺗﺴﺘﺪﻋﻰ ﻗﺒﻞ ﺇﻋﺎﺩﺓ ﺗﺸﻐﻴﻞ ﺍﻟﻨﺸﺎﻁ‬

onDestroy() Called before the Activity is permanently destroyed. .‫ﺗﺴﺘﺪﻋﻰ ﻗﺒﻞ ﺗﺪﻣﻴﺮ ﺍﻟﻨﺸﺎﻁ ﻧﻬﺎﺋﻴﺎ‬

Page 4 | Android Mobile Application Development


4 Show by figure only the relation among methods of activity lifecycle.

Page 5 | Android Mobile Application Development


What is a killable state? What are the killable states? Which state saves
5 data and why?

Killable state: A state in which the Android system can terminate an activity when memory is low.

Killable States:

• onPause()
• onStop()
• onDestroy()

Best State to Save Data:

➜ onPause() — Guaranteed to execute before the activity is killed, giving the app a chance to save its
data before termination.

English ‫ﺍﻟﻌﺮﺑﻴﺔ‬

.‫ ﻫﻮ ﺍﻟﺤﺎﻟﺔ ﺍﻟﺘﻲ ﻳﻤﻜﻦ ﻟﻠﻨﻈﺎﻡ ﻓﻴﻬﺎ ﺇﻳﻘﺎﻑ ﺍﻟﻨﺸﺎﻁ ﻋﻨﺪ ﺍﻧﺨﻔﺎﺽ ﺍﻟﺬﺍﻛﺮﺓ‬killable state ‫ﺍﻟـ‬

:‫ﺍﻟﺤﺎﻻﺕ ﺍﻟﻘﺎﺑﻠﺔ ﻟﻺﻳﻘﺎﻑ‬


onPause() •
onStop() •
onDestroy() •

:‫ﺃﻫﻢ ﺣﺎﻟﺔ ﻟﺤﻔﻆ ﺍﻟﺒﻴﺎﻧﺎﺕ‬


onPause() — ‫ ﻣﻤﺎ ﻳﻌﻄﻴﻪ ﻓﺮﺻﺔ ﻟﺤﻔﻆ ﺍﻟﺒﻴﺎﻧﺎﺕ‬،‫ﻷﻧﻬﺎ ﺍﻟﺤﺎﻟﺔ ﺍﻟﻮﺣﻴﺪﺓ ﺍﻟﺘﻲ ﻳﻀﻤﻦ ﺍﻟﻨﻈﺎﻡ ﺗﻨﻔﻴﺬﻫﺎ ﻗﺒﻞ ﺇﻳﻘﺎﻑ ﺍﻟﺘﻄﺒﻴﻖ‬.

Page 6 | Android Mobile Application Development


6 What is MVC? Describe its components.

MVC (Model-View-Controller) is a software design pattern that separates an application into three
interconnected components.

Components:

• Model: Stores application data and handles business logic. Has no knowledge of the user interface.
• View: The user interface (UI) that displays data to the user and allows interaction.
• Controller: Connects the Model and View. Handles user input and updates both accordingly.

English ‫ﺍﻟﻌﺮﺑﻴﺔ‬

MVC ‫ﻫﻮ ﻧﻤﻂ ﺗﺼﻤﻴﻢ ﺑﺮﻣﺠﻲ ﻳﻘﺴﻢ ﺍﻟﺘﻄﺒﻴﻖ ﺇﻟﻰ ﺛﻼﺛﺔ ﺃﺟﺰﺍﺀ ﻣﺘﺮﺍﺑﻄﺔ‬.

:‫ﺍﻟﻤﻜﻮﻧﺎﺕ‬
Model (‫ ﻻ ﻋﻠﻢ ﻟﻪ ﺑﻮﺍﺟﻬﺔ ﺍﻟﻤﺴﺘﺨﺪﻡ‬.‫ ﻳﺨﺰﻥ ﺑﻴﺎﻧﺎﺕ ﺍﻟﺘﻄﺒﻴﻖ ﻭﻳﺘﻌﺎﻣﻞ ﻣﻊ ﻣﻨﻄﻖ ﺍﻟﻌﻤﻞ‬:(‫ﺍﻟﻨﻤﻮﺫﺝ‬. •
View (‫ ﻭﺍﺟﻬﺔ ﺍﻟﻤﺴﺘﺨﺪﻡ ﺍﻟﺘﻲ ﺗﻌﺮﺽ ﺍﻟﺒﻴﺎﻧﺎﺕ ﻭﺗﺴﻤﺢ ﺑﺎﻟﺘﻔﺎﻋﻞ‬:(‫ﻭﺍﺟﻬﺔ ﺍﻟﻌﺮﺽ‬. •
Controller (‫ ﻳﺮﺑﻂ ﺑﻴﻦ‬:(‫ ﺍﻟﻤﺘﺤﻜﻢ‬Model ‫ ﻭ‬View ‫ﻭﻳﺘﻌﺎﻣﻞ ﻣﻊ ﻣﺪﺧﻼﺕ ﺍﻟﻤﺴﺘﺨﺪﻡ‬. •

Page 7 | Android Mobile Application Development


What is a layout manager? What problem does it solve? Describe two
7 types.

Definition:

A Layout Manager is a class used to arrange and control the positions of different views on the screen.

Problem Solved:

It solved the problem of placing UI components correctly across all screen sizes and dimensions.

Types of Layout Managers:

• Linear Layout: Organizes views in a single horizontal or vertical row.


• Relative Layout: Positions views relative to each other or to the parent container.
• Table Layout: Arranges views in rows and columns, similar to a spreadsheet.

English ‫ﺍﻟﻌﺮﺑﻴﺔ‬

:‫ﺍﻟﺘﻌﺮﻳﻒ‬
.‫ﻣﺪﻳﺮ ﺍﻟﺘﺨﻄﻴﻂ ﻫﻮ ﻛﻼﺱ ﻳﺴﺘﺨﺪﻡ ﻟﺘﺮﺗﻴﺐ ﻭﺍﻟﺘﺤﻜﻢ ﻓﻲ ﺃﻣﺎﻛﻦ ﺍﻟﻌﻨﺎﺻﺮ ﺍﻟﻤﺨﺘﻠﻔﺔ ﻋﻠﻰ ﺍﻟﺸﺎﺷﺔ‬

:‫ﺍﻟﻤﺸﻜﻠﺔ ﺍﻟﺘﻲ ﻳﺤﻠﻬﺎ‬


.‫ﻳﺤﻞ ﻣﺸﻜﻠﺔ ﻭﺿﻊ ﻣﻜﻮﻧﺎﺕ ﺍﻟﻮﺍﺟﻬﺔ ﺑﺸﻜﻞ ﺻﺤﻴﺢ ﻋﻠﻰ ﺟﻤﻴﻊ ﺃﺣﺠﺎﻡ ﻭﺃﺑﻌﺎﺩ ﺍﻟﺸﺎﺷﺎﺕ ﺍﻟﻤﺨﺘﻠﻔﺔ‬

:‫ﺃﻧﻮﺍﻉ ﻣﺪﻳﺮﻱ ﺍﻟﺘﺨﻄﻴﻂ‬


Linear Layout: ‫ﻳﻨﻈﻢ ﺍﻟﻌﻨﺎﺻﺮ ﻓﻲ ﺻﻒ ﻭﺍﺣﺪ ﺃﻓﻘﻲ ﺃﻭ ﺭﺃﺳﻲ‬. •
Relative Layout: ‫ﻳﻀﻊ ﺍﻟﻌﻨﺎﺻﺮ ﻧﺴﺒﺔ ﻟﺒﻌﻀﻬﺎ ﺃﻭ ﻟﻠﺤﺎﻭﻳﺔ ﺍﻷﻡ‬. •
Table Layout: ‫ﻳﺮﺗﺐ ﺍﻟﻌﻨﺎﺻﺮ ﻓﻲ ﺻﻔﻮﻑ ﻭﺃﻋﻤﺪﺓ ﻣﺜﻞ ﺟﺪﻭﻝ ﺍﻟﺒﻴﺎﻧﺎﺕ‬. •

Page 8 | Android Mobile Application Development


8 What is a fragment in Android? Describe the way it works.

A Fragment is a reusable portion of an app's UI that represents a section of a screen.

It has its own layout, lifecycle, and input handling, but cannot exist independently — it must be hosted
inside an Activity or another Fragment.

The fragment's view hierarchy is attached to the host Activity's view hierarchy, making it part of the
Activity's UI.

Fragments make apps modular and reusable. The same fragment can appear in multiple activities or
multiple locations within one activity.

The fragment lifecycle is tied to its host — when the Activity pauses or stops, the Fragment is also
paused or stopped.

English ‫ﺍﻟﻌﺮﺑﻴﺔ‬

Fragment ‫ﻫﻮ ﺟﺰﺀ ﻗﺎﺑﻞ ﻹﻋﺎﺩﺓ ﺍﻻﺳﺘﺨﺪﺍﻡ ﻣﻦ ﻭﺍﺟﻬﺔ ﺍﻟﻤﺴﺘﺨﺪﻡ ﻭﻳﻤﺜﻞ ﻗﺴﻤﺎ ﻣﻦ ﺍﻟﺸﺎﺷﺔ‬.
.‫ ﺁﺧﺮ‬Fragment ‫ ﺃﻭ‬Activity ‫ ﻟﻜﻨﻪ ﻻ ﻳﻌﻤﻞ ﺑﻤﻔﺮﺩﻩ — ﻳﺠﺐ ﺃﻥ ﻳﻜﻮﻥ ﺩﺍﺧﻞ‬،‫ﻟﻪ ﺗﺼﻤﻴﻤﻪ ﻭﺩﻭﺭﺓ ﺣﻴﺎﺗﻪ ﺍﻟﺨﺎﺻﺔ‬
.‫ ﺍﻟﻤﻀﻴﻒ ﻟﺘﺼﺒﺢ ﺟﺰﺀﺍ ﻣﻦ ﻭﺍﺟﻬﺘﻪ‬Activity ‫ ﺗﺪﻣﺞ ﻣﻊ ﺷﺠﺮﺓ ﻋﺮﺽ ﺍﻟـ‬Fragment ‫ﺷﺠﺮﺓ ﻋﺮﺽ‬
.‫ ﻓﻲ ﺃﻛﺜﺮ ﻣﻦ ﻣﻜﺎﻥ‬Fragment ‫ ﻳﻤﻜﻦ ﺍﺳﺘﺨﺪﺍﻡ ﻧﻔﺲ‬.‫ ﺍﻟﺘﻄﺒﻴﻘﺎﺕ ﺃﻛﺜﺮ ﺗﻨﻈﻴﻤﺎ ﻭﺇﻋﺎﺩﺓ ﺍﺳﺘﺨﺪﺍﻡ‬Fragments ‫ﺗﺠﻌﻞ ﺍﻟـ‬
.‫ ﻣﻌﻪ‬Fragments ‫ ﺍﻟﻤﻀﻴﻒ — ﻋﻨﺪ ﺗﻮﻗﻔﻪ ﺗﺘﻮﻗﻒ ﺍﻟـ‬Activity ‫ ﻣﺮﺗﺒﻄﺔ ﺑﺎﻟـ‬Fragment ‫ﺩﻭﺭﺓ ﺣﻴﺎﺓ‬

Page 9 | Android Mobile Application Development


9 What is an Intent? What is its purpose? Describe types of intents.

An Intent is a messaging object used to request an action from another app component — such as
starting an Activity, Service, or delivering a broadcast.

Purpose:

Used to start Activities, start Services, and pass data between application components.

Types of Intents:

• Implicit Intent: Does not name a specific component. The system finds the appropriate app based on
the intent action.
• Explicit Intent: Specifies the exact component (class name) to start within your own application.

English ‫ﺍﻟﻌﺮﺑﻴﺔ‬

Intent ‫ ﻫﻲ ﺭﺳﺎﻟﺔ ﺗﺴﺘﺨﺪﻡ ﻓﻲ ﺃﻧﺪﺭﻭﻳﺪ ﻟﻠﺘﻮﺍﺻﻞ ﺑﻴﻦ ﻣﻜﻮﻧﺎﺕ ﺍﻟﺘﻄﺒﻴﻖ ﻣﺜﻞ‬Activities ‫ ﻭ‬Services.

:‫ﺍﻟﻬﺪﻑ‬
.‫ﺗﺴﺘﺨﺪﻡ ﻟﺒﺪﺀ ﺍﻷﻧﺸﻄﺔ ﺃﻭ ﺍﻟﺨﺪﻣﺎﺕ ﻭﻧﻘﻞ ﺍﻟﺒﻴﺎﻧﺎﺕ ﺑﻴﻦ ﻣﻜﻮﻧﺎﺕ ﺍﻟﺘﻄﺒﻴﻖ‬

:Intents ‫ﺃﻧﻮﺍﻉ ﺍﻟـ‬


Intent ‫( ﺿﻤﻨﻲ‬Implicit): ‫ ﻭﺍﻟﻨﻈﺎﻡ ﻳﺨﺘﺎﺭ ﺍﻟﺘﻄﺒﻴﻖ ﺍﻟﻤﻨﺎﺳﺐ ﺗﻠﻘﺎﺋﻴﺎ‬،‫ﻻ ﻳﺤﺪﺩ ﺍﻟﻤﻜﻮﻥ ﺍﻟﻤﺴﺘﻬﺪﻑ‬. •
Intent ‫( ﺻﺮﻳﺢ‬Explicit): ‫ﻳﺤﺪﺩ ﺍﻟﻤﻜﻮﻥ ﺍﻟﻤﻄﻠﻮﺏ ﺑﺪﻗﺔ ﺑﺎﺳﻢ ﺍﻟﻜﻼﺱ ﺩﺍﺧﻞ ﺍﻟﺘﻄﺒﻴﻖ‬. •

Page 10 | Android Mobile Application Development


10 Compare between Threads and Services.

Aspect Service Thread

Nature Android component running in background Lightweight unit inside a process

Lifecycle Has independent lifecycle from Activity No independent lifecycle

Restart Can be restarted by system when stopped Cannot be automatically restarted

Use Case Long-running tasks (e.g. music playback) Short tasks (e.g. calculations)

English ‫ﺍﻟﻌﺮﺑﻴﺔ‬

■■■■■■■■ ■■■ Service Thread

‫ﺍﻟﻄﺒﻴﻌﺔ‬ ‫ﻣﻜﻮﻥ ﺃﻧﺪﺭﻭﻳﺪ ﻳﻌﻤﻞ ﻓﻲ ﺍﻟﺨﻠﻔﻴﺔ‬ ‫ﺟﺰﺀ ﺧﻔﻴﻒ ﺩﺍﺧﻞ ﺍﻟﻌﻤﻠﻴﺔ‬

‫ﺩﻭﺭﺓ ﺍﻟﺤﻴﺎﺓ‬ Activity ‫ ﻣﺴﺘﻘﻞ ﻋﻦ‬lifecycle ‫ﻟﻪ‬ ‫ ﻣﺴﺘﻘﻞ‬lifecycle ‫ﻻ ﻳﻤﻠﻚ‬

‫ﺇﻋﺎﺩﺓ ﺍﻟﺘﺸﻐﻴﻞ‬ ‫ﻳﻤﻜﻦ ﻟﻠﻨﻈﺎﻡ ﺇﻋﺎﺩﺓ ﺗﺸﻐﻴﻠﻪ‬ ‫ﻻ ﻳﻌﺎﺩ ﺗﺸﻐﻴﻠﻪ ﺗﻠﻘﺎﺋﻴﺎ‬

‫ﺣﺎﻟﺔ ﺍﻻﺳﺘﺨﺪﺍﻡ‬ ‫ﻣﻬﺎﻡ ﻃﻮﻳﻠﺔ ﻣﺜﻞ ﺗﺸﻐﻴﻞ ﺍﻟﻤﻮﺳﻴﻘﻰ‬ ‫ﻣﻬﺎﻡ ﻗﺼﻴﺮﺓ ﻣﺜﻞ ﺍﻟﺤﺴﺎﺑﺎﺕ‬

Page 11 | Android Mobile Application Development


Describe and show by figure the difference between bound and unbound
11 services.

Bound Service:

• Components bind to it using bindService().


• Runs only while components are bound to it (multiple components can bind at once).
• Stopped automatically when all clients unbind.

Unbound Service:

• Runs independently after being started with startService().


• Foreground: Notifies the user (shows notification) and allows interaction.
• Background: Runs silently without notifying the user.

English ‫ﺍﻟﻌﺮﺑﻴﺔ‬

:(Bound Service) ‫ﺍﻟﺨﺪﻣﺔ ﺍﻟﻤﺮﺑﻮﻃﺔ‬


.()bindService ‫• ﺗﻘﻮﻡ ﺍﻟﻤﻜﻮﻧﺎﺕ ﺑﺎﻻﺭﺗﺒﺎﻁ ﺑﻬﺎ ﺑﺎﺳﺘﺨﺪﺍﻡ ﺍﻟﺪﺍﻟﺔ‬
.‫• ﺗﻌﻤﻞ ﻓﻘﻂ ﻃﺎﻟﻤﺎ ﺃﻥ ﻫﻨﺎﻙ ﻣﻜﻮﻧﺎﺕ ﻣﺮﺗﺒﻄﺔ ﺑﻬﺎ ﻭﻳﻤﻜﻦ ﻟﻌﺪﺓ ﻣﻜﻮﻧﺎﺕ ﺍﻻﺭﺗﺒﺎﻁ ﻓﻲ ﻧﻔﺲ ﺍﻟﻮﻗﺖ‬
.‫• ﺗﺘﻮﻗﻒ ﺗﻠﻘﺎﺋﻴﺎ ﻋﻨﺪ ﺇﻟﻐﺎﺀ ﺍﺭﺗﺒﺎﻁ ﺟﻤﻴﻊ ﺍﻟﻌﻤﻼﺀ‬

:(Unbound Service) ‫ﺍﻟﺨﺪﻣﺔ ﻏﻴﺮ ﺍﻟﻤﺮﺑﻮﻃﺔ‬


.()startService ‫• ﺗﻌﻤﻞ ﺑﺸﻜﻞ ﻣﺴﺘﻘﻞ ﺗﻤﺎﻣﺎ ﺑﻌﺪ ﺗﺸﻐﻴﻠﻬﺎ ﺑﺎﺳﺘﺨﺪﺍﻡ‬
.‫ ﺗﻨﺒﻪ ﺍﻟﻤﺴﺘﺨﺪﻡ ﺑﻮﺟﻮﺩﻫﺎ ﻭﺗﺴﻤﺢ ﻟﻪ ﺑﺎﻟﺘﻔﺎﻋﻞ‬:(Foreground) ‫• ﺧﺪﻣﺔ ﻓﻲ ﺍﻟﻮﺍﺟﻬﺔ‬
.‫ ﺗﻌﻤﻞ ﺑﺼﻤﺖ ﺩﻭﻥ ﺗﻨﺒﻴﻪ ﺍﻟﻤﺴﺘﺨﺪﻡ‬:(Background) ‫• ﺧﺪﻣﺔ ﻓﻲ ﺍﻟﺨﻠﻔﻴﺔ‬

Page 12 | Android Mobile Application Development


Page 13 | Android Mobile Application Development
12 Compare between static and dynamic broadcast receivers.

Feature Static Receiver Dynamic Receiver

Registration In [Link] At runtime via registerReceiver()

App State Works even if app is not running Works only when the app is running

Lifecycle Independent of app components Tied to the registering component

Performance Consumes more resources More efficient (active only when needed)

System events (device boot, battery


Examples App events (network changes, clicks)
changes)

English ‫ﺍﻟﻌﺮﺑﻴﺔ‬

■■■■■■■■ ■■■ (Static) ■■■■■■ ■■■■■■■■ (Dynamic) ■■■■■■■■■■ ■■■■■■■■

‫ﺍﻟﺘﺴﺠﻴﻞ‬ [Link] ‫ﻓﻲ‬ ()registerReceiver ‫ﺃﺛﻨﺎﺀ ﺍﻟﺘﺸﻐﻴﻞ ﻋﺒﺮ‬

‫ﺣﺎﻟﺔ ﺍﻟﺘﻄﺒﻴﻖ‬ ‫ﻳﻌﻤﻞ ﺣﺘﻰ ﻟﻮ ﺍﻟﺘﻄﺒﻴﻖ ﻣﻐﻠﻖ‬ ‫ﻳﻌﻤﻞ ﻓﻘﻂ ﻭﺍﻟﺘﻄﺒﻴﻖ ﻳﻌﻤﻞ‬

‫ﺩﻭﺭﺓ ﺍﻟﺤﻴﺎﺓ‬ ‫ﻣﺴﺘﻘﻞ ﻋﻦ ﻣﻜﻮﻧﺎﺕ ﺍﻟﺘﻄﺒﻴﻖ‬ ‫ﻣﺮﺗﺒﻂ ﺑﺪﻭﺭﺓ ﺣﻴﺎﺓ ﺍﻟﻤﻜﻮﻥ ﺍﻟﺬﻱ ﺳﺠﻠﻪ‬

‫ﺍﻷﺩﺍﺀ‬ ‫ﻳﺴﺘﻬﻠﻚ ﻣﻮﺍﺭﺩ ﺃﻛﺜﺮ‬ ‫ ﻳﻌﻤﻞ ﻋﻨﺪ ﺍﻟﺤﺎﺟﺔ ﻓﻘﻂ‬- ‫ﺃﻛﺜﺮ ﻛﻔﺎﺀﺓ‬

‫ﺃﻣﺜﻠﺔ‬ ‫ﺃﺣﺪﺍﺙ ﺍﻟﻨﻈﺎﻡ ﻣﺜﻞ ﺇﻋﺎﺩﺓ ﺍﻟﺘﺸﻐﻴﻞ‬ ‫ﺃﺣﺪﺍﺙ ﺍﻟﺘﻄﺒﻴﻖ ﻣﺜﻞ ﺗﻐﻴﺮ ﺍﻟﺸﺒﻜﺔ‬

Page 14 | Android Mobile Application Development


Describe and draw a figure of interaction between content provider, other
13 classes and storage.

Components:

• Activity / Fragment (UI): Calls CursorLoader to query data asynchronously in the background.
• Content Resolver: Acts as a broker — receives the request and routes it to the correct provider using a
unique Authority.
• Content Provider: Directly manages and handles access to the Data Storage (Database).
• Data Storage: The actual database (e.g., SQLite) where data is stored.

English ‫ﺍﻟﻌﺮﺑﻴﺔ‬

:‫ﺍﻟﻤﻜﻮﻧﺎﺕ‬
Activity / Fragment (‫ ﺗﻄﻠﺐ ﺍﻟﺒﻴﺎﻧﺎﺕ ﻓﻲ ﺍﻟﺨﻠﻔﻴﺔ ﻋﻦ ﻃﺮﻳﻖ‬:(‫ ﺍﻟﻮﺍﺟﻬﺔ‬CursorLoader. •
Content Resolver (‫ ﻳﺴﺘﻘﺒﻞ ﺍﻟﻄﻠﺐ ﻭﻳﻮﺟﻬﻪ ﻟﻠﻤﺰﻭﺩ ﺍﻟﺼﺤﻴﺢ ﺑﺎﺳﺘﺨﺪﺍﻡ ﺍﻟـ‬:(‫ ﺍﻟﻮﺳﻴﻂ‬Authority. •
Content Provider (‫ ﻳﺘﻌﺎﻣﻞ ﻣﺒﺎﺷﺮﺓ ﻣﻊ ﻗﺎﻋﺪﺓ ﺍﻟﺒﻴﺎﻧﺎﺕ ﻟﺠﻠﺐ ﺃﻭ ﺣﻔﻆ ﺍﻟﺒﻴﺎﻧﺎﺕ‬:(‫ﺍﻟﻤﺰﻭﺩ‬. •
Data Storage (‫ ﻗﺎﻋﺪﺓ ﺍﻟﺒﻴﺎﻧﺎﺕ ﺍﻟﻔﻌﻠﻴﺔ ﻣﺜﻞ‬:(‫ ﺍﻟﺘﺨﺰﻳﻦ‬SQLite ‫ﺣﻴﺚ ﺗﺨﺰﻥ ﺍﻟﺒﻴﺎﻧﺎﺕ‬. •

Page 15 | Android Mobile Application Development


14 Compare between Content Provider and Content Resolver.

Feature Content Provider Content Resolver

Server side: manages, stores and shares Client side: communicates with the provider
Role
data with other apps. via URI for CRUD operations.

Subclass of ContentProvider that defines Uses methods like query(), insert(), update(),
Implementation
CRUD methods. delete() to call the provider.

Enforces permissions to control who can Requires permissions granted by the


Security
access its data. provider to access the data.

Like a client that queries the database


Analogy Like a database server exposing an API.
through that API.

English ‫ﺍﻟﻌﺮﺑﻴﺔ‬

■■■■■■■■ ■■■ Content Provider Content Resolver

.‫ ﻳﺪﻳﺮ ﺍﻟﺒﻴﺎﻧﺎﺕ ﻭﻳﺸﺎﺭﻛﻬﺎ ﻣﻊ ﺍﻟﺘﻄﺒﻴﻘﺎﺕ ﺍﻷﺧﺮﻯ‬:‫ﺍﻟﺴﻴﺮﻓﺮ‬ .CRUD ‫ ﻟﺘﻨﻔﻴﺬ ﻋﻤﻠﻴﺎﺕ‬URI ‫ﻳﺘﻮﺍﺻﻞ ﻣﻊ ﺍﻟﻤﺰﻭﺩ ﻋﺒﺮ‬
‫ﺍﻟﺪﻭﺭ‬
‫ﺟﺎﻧﺐ‬ :‫ﺟﺎﻧﺐ ﺍﻟﻌﻤﻴﻞ‬

.‫)( ﻟﻠﻮﺻﻮﻝ ﻟﻠﻤﺰﻭﺩ‬insert ‫)( ﻭ‬query ‫ﺟﺎﻫﺰﺓ ﻣﺜﻞ‬


‫ﺍﻟﺘﻨﻔﻴﺬ‬ .‫ﻛﻼﺱ ﻓﺮﻋﻲ ﻳﻌﺮﻑ ﺩﻭﺍﻝ ﺍﻟﺘﻌﺎﻣﻞ ﻣﻊ ﺍﻟﺒﻴﺎﻧﺎﺕ‬
‫ﻳﺴﺘﺨﺪﻡ ﺩﻭﺍﻝ‬

‫ﺍﻷﻣﺎﻥ‬ .‫ﻳﻔﺮﺽ ﺍﻟﺼﻼﺣﻴﺎﺕ ﻟﻠﺘﺤﻜﻢ ﻓﻴﻤﻦ ﻳﺼﻞ ﻟﺒﻴﺎﻧﺎﺗﻪ‬ .‫ﻳﻄﻠﺐ ﺍﻟﺼﻼﺣﻴﺎﺕ ﻣﻦ ﺍﻟﻤﺰﻭﺩ ﻟﻠﻮﺻﻮﻝ ﻟﻠﺒﻴﺎﻧﺎﺕ‬

‫ﺍﻟﺘﺸﺒﻴﻪ‬ .API ‫ﻣﺜﻞ ﺳﻴﺮﻓﺮ ﻗﺎﻋﺪﺓ ﺑﻴﺎﻧﺎﺕ ﻳﻘﺪﻡ ﻭﺍﺟﻬﺔ‬ .‫ﻣﺜﻞ ﻋﻤﻴﻞ ﻳﺴﺘﻌﻠﻢ ﻣﻦ ﻗﺎﻋﺪﺓ ﺍﻟﺒﻴﺎﻧﺎﺕ ﻋﺒﺮ ﺗﻠﻚ ﺍﻟﻮﺍﺟﻬﺔ‬

Page 16 | Android Mobile Application Development

You might also like