0% found this document useful (0 votes)
25 views19 pages

Mobal

Chapter 5 provides an overview of network communication, detailing the roles of clients and servers, as well as the components involved in data transmission such as packets, routers, and switches. It also covers telephony systems, communication models, and Android networking, emphasizing the importance of efficient memory management and notifications in mobile applications. Additionally, it includes multiple-choice questions to reinforce the concepts discussed in the chapter.

Uploaded by

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

Mobal

Chapter 5 provides an overview of network communication, detailing the roles of clients and servers, as well as the components involved in data transmission such as packets, routers, and switches. It also covers telephony systems, communication models, and Android networking, emphasizing the importance of efficient memory management and notifications in mobile applications. Additionally, it includes multiple-choice questions to reinforce the concepts discussed in the chapter.

Uploaded by

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

Chapter 5

Introduction to Network Communication

 Network communication enables different applications to interact using protocols.


 Client: A process requesting services on a network.
 Server: A process responding to client requests.

Network and Web Communication

 Packets: Data units sent over the Internet.


 Hub: Broadcasts packets to all connected devices.
 Switch: Directs packets only to the intended recipient.
 Bridge: Connects multiple LANs.
 Router: Routes packets towards their destinations.

IP Addresses and Domain Names

 IP Address: Unique identifier for internet-connected devices.


 Domain Name: Human-readable address mapped to an IP.
 DNS (Domain Name System): Resolves domain names into IP addresses.
 Packet Switching: Data packets take different routes to their destination.

Telephony

 Traditional Telephony: Converts sound into electrical signals over PSTN.


 Internet Telephony (VoIP): Uses the Internet for cost-effective calls.

Types of Telephony Systems

1. Circuit-Switched PBX: Uses traditional dedicated lines.


2. VoIP PBX: Private phone network via the Internet.
3. Hybrid PBX: Combination of PBX and VoIP.
4. Cloud VoIP: Hosted VoIP services eliminating on-site infrastructure.

State Machines

 A model for designing computer programs and digital systems.


 Composed of states, transitions, and actions.

Communication Models

1. One-Way Model: Linear communication from sender to receiver.


2. Interactive Model: Two-way exchange based on feedback.
3. Transactional Model: Continuous exchange between sender and receiver.

Defining Scope of an App


 Key steps: Defining goals, identifying challenges, allocating resources, setting milestones, and
listing stakeholders.

Android Networking

 Android apps use ConnectivityManager to check network status.


 Permissions required: INTERNET and ACCESS_NETWORK_STATE.

Wireless Connectivity

 Bluetooth: Short-range wireless communication.


 802.11 (Wi-Fi): Standard for wireless local area networks.
 Mobile Networks (1G-5G): Evolution of cellular communication technologies.

Android Telephony

 Android provides a telephony API to manage calls, SMS, and network status.
 Call initiation example: Using Intent.ACTION_CALL.

Performance & Memory Management

 Efficient memory management is crucial for mobile apps due to hardware constraints.

Android Notifications and Alarms

 Notifications: Alerts users about events using NotificationCompat.Builder.


 Alarms: Scheduled tasks using AlarmManager.

Chapter 5: Communications via Network and the Web - Multiple Choice


Questions

1.

What is the fundamental unit of data transmitted over the Internet? a) Bit
b) Byte
c) Packet
d) Frame
Answer: c) Packet

2.
3.

Which device connects multiple devices in a network and filters packets? a)


Hub
b) Router
c) Switch
d) Bridge
Answer: c) Switch

4.
5.
What does DNS stand for? a) Digital Network System
b) Domain Name System
c) Data Node System
d) Dynamic Name Server
Answer: b) Domain Name System

6.
7.

Which of the following best describes VoIP? a) A protocol for email


communication
b) A way to make voice calls over the Internet
c) A high-speed internet connection
d) A type of local network
Answer: b) A way to make voice calls over the Internet

8.
9.

What is the primary function of a router? a) Connect multiple devices in a


LAN
b) Route packets towards their destination
c) Store website data
d) Convert digital signals into analog
Answer: b) Route packets towards their destination

10.
11.

What is the purpose of an IP address? a) To secure data packets


b) To uniquely identify devices on the Internet
c) To store domain names
d) To encrypt communication
Answer: b) To uniquely identify devices on the Internet

12.
13.

Which communication model follows a linear path from sender to receiver? a)


Interactive Model
b) Transactional Model
c) One-Way Model
d) Feedback Model
Answer: c) One-Way Model

14.
15.
What is an example of Internet telephony? a) Email
b) VoIP
c) SMS
d) Fiber-optic communication
Answer: b) VoIP

16.
17.

In which generation of mobile networks was SMS introduced? a) 1G


b) 2G
c) 3G
d) 4G
Answer: b) 2G

18.
19.

What is the main advantage of packet-switching over circuit-switching? a)


Uses a dedicated path for each connection
b) More efficient and fault-tolerant
c) Requires less data
d) Works only for voice calls
Answer: b) More efficient and fault-tolerant

20.

Summary of Chapter 4: Storing and Retrieving Data in


Android

1. Introduction

 Android offers various ways to store and share data, including:


1. File-system access
2. SQLite relational database
3. SharedPreferences (for storing key-value pairs)
 SharedPreferences allows saving and retrieving simple data between activities, with options
for privacy settings.

2. Synchronization and Replication of Mobile Data

 Ensures data consistency across multiple locations.


 Data is cleaned, checked for errors, and updated in real time.
 Prevents redundant data transfers by syncing only additions, changes, and deletions.
 Types of synchronization methods:
o File Synchronization: Keeps multiple locations updated (e.g., local-to-cloud).
o Version Control: Tracks file changes (e.g., Git).
o Distributed File Systems: Stores data across multiple machines (e.g., HDFS).
o Mirror Computing: Creates an exact copy for load balancing (e.g., website mirrors).

3. Working with SharedPreferences

 Modes:
o MODE_PRIVATE: Restricts access to the application.
o MODE_PUBLIC: Allows access by other applications.
o MODE_APPEND: Used for appending data.
 Key Methods:

o edit() – Creates an editor to modify data.


o getAll() – Retrieves all values.
o getBoolean(), getInt(), getFloat() – Fetches specific data types.

 Example:

o Storing and retrieving user preferences such as name and age.

4. Using Internal Storage

 Files saved in internal storage are private and deleted upon app uninstallation.
 To write data:

1. Call openFileOutput().
2. Write using write().
3. Close with close().

 To read data:

1. Call openFileInput().
2. Read bytes with read().
3. Close with close().

 Example:

o Writing and reading from "hello_file.txt" using FileOutputStream and


FileInputStream.

5. Using Databases (SQLite)

 SQLite is built into Android and used for lightweight, embedded databases.
 Creating a database:

o Subclass SQLiteOpenHelper.
o Override onCreate() and onUpgrade().
 Database operations:

o Insert data: insert()


o Delete data: delete()
o Update data: update()
o Retrieve data: Using Cursor

 Example:

o Creating a table, inserting, updating, and deleting student details.

6. Working with Content Providers

 Content Providers manage shared app data and allow secure access.
 Data can be stored in SQLite, files, or other formats.
 Content URI Structure: content://authority/optionalPath/optionalID

o Authority: Identifies the content provider.


o Optional Path: Defines data type (e.g., contacts, images).
o Optional ID: Specifies a particular record.

 Key methods:

o query() – Fetches data.


o insert() – Adds new data.
o update() – Modifies existing data.
o delete() – Removes data.
o onCreate() – Initializes the provider.

1. Which of the following is NOT a data storage option


in Android?

a) SharedPreferences
b) SQLite Database
c) XML Storage
d) Internal Storage

Answer: c) XML Storage

2. What is SharedPreferences primarily used for?

a) Storing relational database data


b) Storing simple key-value pairs
c) Storing large files
d) Storing multimedia data

Answer: b) Storing simple key-value pairs


3. What mode in SharedPreferences makes data
accessible only within the application?

a) MODE_APPEND
b) MODE_PRIVATE
c) MODE_PUBLIC
d) MODE_SECURE

Answer: b) MODE_PRIVATE

4. What does data synchronization ensure?

a) Data is always consistent across different sources


b) Data is only stored on a local device
c) Data is deleted automatically when not in use
d) Data is transferred without verification

Answer: a) Data is always consistent across different sources

5. What method is used to store a String in


SharedPreferences?

a) putInt()
b) putFloat()
c) putString()
d) putBoolean()

Answer: c) putString()

6. What is the role of the SQLiteOpenHelper class in


Android?

a) To create and manage SQLite databases


b) To store key-value pairs
c) To handle JSON storage
d) To sync cloud data

Answer: a) To create and manage SQLite databases


7. Which method is called when a SQLite database is
first created?

a) onUpgrade()
b) onCreate()
c) onDestroy()
d) onSync()

Answer: b) onCreate()

8. What does the execSQL() method do in SQLite?

a) Executes a single SQL statement


b) Fetches data from the database
c) Syncs databases with the cloud
d) Deletes the database

Answer: a) Executes a single SQL statement

9. What method is used to delete data from an SQLite


database?

a) remove()
b) delete()
c) erase()
d) clear()

Answer: b) delete()

10. Which Android storage method provides


structured storage using tables?

a) SharedPreferences
b) SQLite Database
c) Internal Storage
d) External Storage

Answer: b) SQLite Database

11. What is the main advantage of data


synchronization?
a) Reduces data loss and ensures consistency
b) Automatically backs up all data
c) Reduces memory usage
d) Deletes duplicate records automatically

Answer: a) Reduces data loss and ensures consistency

12. Which file system stores files across multiple


machines as a single system?

a) SharedPreferences
b) Distributed File System
c) Internal Storage
d) Version Control System

Answer: b) Distributed File System

13. Which data synchronization method is commonly


used for source code collaboration?

a) File Synchronization
b) Version Control
c) Mirror Computing
d) Cloud Backup

Answer: b) Version Control

14. Which method retrieves all values from


SharedPreferences?

a) getAll()
b) getValues()
c) retrieveData()
d) fetchAll()

Answer: a) getAll()

15. What happens to files stored in internal storage


when an app is uninstalled?
a) They remain on the device
b) They are automatically deleted
c) They are moved to external storage
d) They are synced with cloud storage

Answer: b) They are automatically deleted

16. Which command writes data to a file in internal


storage?

a) writeFile()
b) openFileOutput()
c) storeData()
d) saveFile()

Answer: b) openFileOutput()

17. What is the default access level for files stored in


internal storage?

a) Public
b) Private
c) Shared
d) Encrypted

Answer: b) Private

18. Which method is used to insert data into an


SQLite database?

a) add()
b) insert()
c) store()
d) put()

Answer: b) insert()

19. What component allows Android apps to share


structured data with other apps?
a) SharedPreferences
b) SQLiteOpenHelper
c) Content Providers
d) File Storage

Answer: c) Content Providers

20. What is the purpose of a Content URI in a Content


Provider?

a) It represents the path to a specific data source


b) It is used to store large files
c) It encrypts database queries
d) It is a built-in Android security feature

Answer: a) It represents the path to a specific data source

Summary of Chapter 6: Graphics and Multimedia in


Android

1. Performance and Multithreading


 Multithreading allows multiple threads to run simultaneously within a process, improving
app performance.
 Example of creating a
background thread in Android:

java


CopyEdit


Thread backgroundThread = new Thread(new Runnable() {


public void run() {
// Background task
runOnUiThread(new Runnable() {
public void run() {
// Update UI with results
}
});
}
});
backgroundThread.start();



 Reading Assignment: Handlers in threads.

2. Graphics and UI Performance


 Good UI performance enhances user experience and app responsiveness.
 Best practices:

o Use efficient layouts like ConstraintLayout to avoid performance bottlenecks.


o Minimize nested views and overlapping elements.
o Test UI on devices with different screen sizes and hardware configurations.

3. Android Animations
 Android offers multiple animation systems for enhancing user interfaces.
 View Animation: Simple transformations like moving, resizing, and rotation.
 Example (Fade In
Fade Out Animatio

java


CopyEdit


Animation fadeIn = new AlphaAnimation(0, 1);


fadeIn.setDuration(1000);
view.startAnimation(fadeIn);



java



CopyEdit


Animation fadeOut = new AlphaAnimation(1, 0);


fadeOut.setDuration(1000);
view.startAnimation(fadeOut);



 Drawable Animation: Uses multiple images in sequence to create animations.

o Example XML defin


o

xml

o
o

CopyEdit

o
o

<animation-list
xmlns:android="http://schemas.android.com/apk/res/an
droid"
android:oneshot="false">
<item android:drawable="@drawable/frame1"
android:duration="100"/>
<item android:drawable="@drawable/frame2"
android:duration="100"/>
<item android:drawable="@drawable/frame3"
android:duration="100"/></animation-list>

o
o
o Java Code:
o

java

o
o

CopyEdit

o
o
ImageView imageView =
findViewById(R.id.imageView);
imageView.setBackgroundResource(R.drawable.animat
ion_list);AnimationDrawable animationDrawable =
(AnimationDrawable) imageView.getBackground();
animationDrawable.start();

o
o

4. Multimedia Mobile Agents & Peer-to-Peer (P2P)


Architecture
 Multimedia Mobile Agents (MMAs):

o Software entities that move between devices to transfer and process multimedia.
o Can carry, process, and make decisions about multimedia files.

 P2P Architecture:
o Devices share files without a central server.
o Each device helps others by sharing storage and processing power.

5. Android Multimedia
 Android provides the MediaPlayer class for playing audio and video.
 Creating a MediaPlayer
instance:

java


CopyEdit


MediaPlayer mediaPlayer = MediaPlayer.create(this,


R.raw.song);
mediaPlayer.start();



 Key Methods:
o .start() – Starts media playback.
o .pause() – Pauses playback.
o .stop() – Stops playback.
o .release() – Releases MediaPlayer resources.

Here are 20 multiple-choice questions based on Chapter 6: Graphics and


Multimedia in Android.

1. What is multithreading?

a) Running multiple processes at the same time


b) Running multiple threads within a single process
c) Running multiple apps on an Android device
d) Running a single thread within a process

Answer: b) Running multiple threads within a single process

2. Which method is used to start a thread in Android?

a) run()
b) start()
c) execute()
d) begin()

Answer: b) start()

3. Why is UI performance important in Android apps?

a) It makes the app visually appealing


b) It improves user experience and responsiveness
c) It reduces battery consumption
d) It allows the app to run on all Android versions

Answer: b) It improves user experience and responsiveness

4. Which layout is recommended for better


performance in complex UI designs?

a) RelativeLayout
b) LinearLayout
c) ConstraintLayout
d) FrameLayout

Answer: c) ConstraintLayout
5. What is the best way to avoid UI performance
issues?

a) Use nested layouts


b) Use fewer views and optimize layout hierarchy
c) Use only RelativeLayout
d) Use images instead of text

Answer: b) Use fewer views and optimize layout hierarchy

6. What type of animation does Android provide for


simple transformations?

a) View Animation
b) Drawable Animation
c) Frame Animation
d) Video Animation

Answer: a) View Animation

7. Which class is used for creating animations in


Android?

a) AnimationManager
b) AnimationDrawable
c) AnimationView
d) AnimationHandler

Answer: b) AnimationDrawable

8. What does the AlphaAnimation class do?

a) Changes the size of an object


b) Rotates an object
c) Changes the transparency of an object
d) Moves an object

Answer: c) Changes the transparency of an object


9. Which XML tag is used for defining a drawable
animation?

a) <animation-list>
b) <frame-animation>
c) <drawable-animation>
d) <image-list>

Answer: a) <animation-list>

10. How do you start an animation in Android?

a) animation.start()
b) animation.play()
c) animation.begin()
d) animation.run()

Answer: a) animation.start()

11. What is the purpose of Multimedia Mobile Agents?

a) To store multimedia files permanently


b) To move, process, and manage multimedia files across devices
c) To provide built-in animations in Android apps
d) To handle UI performance issues

Answer: b) To move, process, and manage multimedia files across devices

12. How does Peer-to-Peer (P2P) architecture work?

a) Devices rely on a central server for data sharing


b) Devices communicate directly with each other
c) Data is always stored in the cloud
d) Devices only receive data but do not share

Answer: b) Devices communicate directly with each other

13. What is the role of MMAPPA in multimedia?

a) It reduces the size of multimedia files


b) It facilitates multimedia data sharing using P2P networks
c) It stores multimedia data in cloud servers
d) It prevents the sharing of multimedia files

Answer: b) It facilitates multimedia data sharing using P2P networks

14. Which Android class is used to play audio and


video?

a) AudioManager
b) VideoView
c) MediaPlayer
d) MediaManager

Answer: c) MediaPlayer

15. Which method is used to start playing media in


MediaPlayer?

a) play()
b) begin()
c) start()
d) launch()

Answer: c) start()

16. What happens when you call release() on a


MediaPlayer object?

a) It pauses the playback


b) It stops the media and releases resources
c) It restarts the media file
d) It increases the playback speed

Answer: b) It stops the media and releases resources

17. Which method pauses media playback in


MediaPlayer?

a) pause()
b) stop()
c) halt()
d) suspend()

Answer: a) pause()

18. What is the purpose of create() method in


MediaPlayer?

a) To load a media file for playback


b) To delete media files
c) To encode media files
d) To compress media files

Answer: a) To load a media file for playback

19. How can multimedia data be shared efficiently in a


distributed system?

a) Using cloud storage only


b) Using Multimedia Mobile Agents and P2P architecture
c) Using USB file transfer
d) Using local device storage only

Answer: b) Using Multimedia Mobile Agents and P2P architecture

20. Which feature helps improve multimedia


performance in Android applications?

a) Using optimized media formats


b) Using larger file sizes
c) Running multimedia processing on the main UI thread
d) Using only one thread for media playback

Answer: a) Using optimized media formats

You might also like