You are on page 1of 99

Department of Computer College of

Engineering Engineering
SɅRɅSWɅTI

Saraswati College of Engineering


Vision
To become center of excellence in Engineering education and research.

Mission
 To educate Students to become responsible & quality technocrats to fulfill
society and industry needs.
 To nurture student’s creativity and skills for taking up challenges in all facets
of life.

Department of Computer Engineering

Vision
To be among renowned institution in computer engineering education and
research by developing globally competent graduates.
Mission
 To produce eminent Engineering graduates by imparting quality teaching
learning and providing hands on experience in programming to fulfill
society and industry needs.
 To encourage students to pursue research and learn new technologies in
Computer Engineering and across interdisciplinary areas so that they
participate in research, innovation and entrepreneurship.

 To provide stimulating learning ambience to enhance innovative ideas,


problem solving ability, leadership qualities, team-spirit and ethical
responsibilities.

i
SɅRɅSWɅTI
Department of Computer College of
Engineering Engineering
SɅRɅSWɅTI

Mobile Computing Lab

Doc. No: AP/MAN-CSL603 Rev. No. 00 Rev. Dt. : 00

Issue No.: 01 Issued date: 20.01.2022

DEPARTMENT OF COMPUTER
ENGINEERING

LABORATORY MANUAL

COURSE: Mobile Computing Lab

COURSE CODE: CSL603

Semester-V

ii
SɅRɅSWɅTI
Department of Computer College of
Engineering Engineering
SɅRɅSWɅTI

INDEX

Sr. No. Topic Page No.

1 Program Educational Objectives (PEO's) iv

2 Program Outcomes (PO's) v

3 Program Specific Outcomes (PSO's) vi

4 Syllabus vii

5 Course Objectives and Course Outcomes x

6 CO-PO Mapping Matrix and CO-PSO Mapping Matrix xi

7 List of Experiments xii

iii
SɅRɅSWɅTI
Department of Computer College of
Engineering Engineering
SɅRɅSWɅTI

Program Educational Objectives (PEO)

The following are the envisaged as Educational Objectives of Computer Engineering


Program:

1) To embed a strong foundation of Computer Engineering fundamentals to identify,


solve, analyze & design real time Engineering problem as a professional or an
entrepreneur for the benefit of society.
2) To motivate & prepare students for lifelong learning & research to manifest global
competitiveness.
3) To equip students with communication, team work & leadership skills to accept
challenges in all facets of life ethically.

iv
SɅRɅSWɅTI
Department of Computer College of
Engineering Engineering
SɅRɅSWɅTI

Program Outcomes (PO's)


At the end of the course Students will be able to:

1) Apply the knowledge of Mathematics, Science and Engineering Fundamentals to solve


complex Computer Engineering Problems.
2) Identify, formulate and analyze Computer Engineering Problems and derive conclusion
using First Principle of Mathematics, Engineering Science and Computer Science.
3) Investigate Complex Computer Engineering problems to find appropriate solution
leading to valid conclusion.
4) Design a software System, components, Process to meet specified needs with
appropriate attention to health and Safety Standards, Environmental and Societal
Considerations.
5) Create, select and apply appropriate techniques, resources and advance Engineering
software to analyze tools and design for Computer Engineering Problems.
6) Understand the Impact of Computer Engineering solution on society and environment
for Sustainable development.
7) Understand Societal, health, Safety, cultural, Legal issues and Responsibilities relevant
to Engineering Profession.
8) Apply Professional ethics, accountability and equity in Engineering Profession.
9) Work Effectively as a member and leader in multidisciplinary team for a common goal.
10) Communicate Effectively within a Profession and Society at large.
11) Appropriately incorporate principles of Management and Finance in one’s own Work.
12) Identify educational needs and engage in lifelong learning in a Changing World of
Technology.

v
SɅRɅSWɅTI
Department of Computer College of
Engineering Engineering
SɅRɅSWɅTI

Program Specific Outcomes (PSO)

1) Formulate and analyze complex engineering problems in computer engineering


(Networking/Big data/ Intelligent Systems/Cloud Computing/Real time systems).
2) Plan and develop efficient, reliable, secure and customized application software using
cost effective emerging software tools ethically.

vi
SɅRɅSWɅTI
Department of Computer College of
Engineering Engineering
SɅRɅSWɅTI

University Syllabus for the subject and lab


Module Detailed Contents Hours

1.1 Introduction to Mobile Computing, Telecommunication


Generations, Cellular systems,
1. 1.2 Electromagnetic Spectrum, Antenna, Signal Propagation, 04

Signal Characteristics, Multiplexing, Spread Spectrum: DSSS


& FHSS, Cochannel interference

GSM Mobile services


2.1 GSM Mobile services, System Architecture, Radio
interface, Protocols, Localization and Calling, Handover,
2. security (A3, A5 & A8) 08

2.2 GPRS system and protocol architecture


2.3 UTRAN, UMTS core network; Improvements on Core
Network,
Mobile Networking
3.1 Medium Access Protocol, Internet Protocol and Transport
layer
3.2 Mobile IP: IP Packet Delivery, Agent Advertisement and

3. Discovery, Registration, Tunneling and Encapsulation, Reverse 08


Tunneling.
3.3 Mobile TCP: Traditional TCP, Classical TCP
Improvements like Indirect TCP, Snooping TCP & Mobile
TCP, Fast Retransmit/ Fast Recovery, Transmission/Timeout
Freezing, Selective Retransmission
Wireless Local Area Networks
4.1 Wireless Local Area Networks: Introduction, Infrastructure
4. and ad-hoc network 06

4.2 IEEE 802.11:System architecture , Protocol architecture ,


Physical layer, Medium access control layer, MAC

vii
SɅRɅSWɅTI
Department of Computer College of
Engineering Engineering
SɅRɅSWɅTI
management, 802.11a, 802.11b standard
4.3 Wi-Fi security : WEP ,WPA, Wireless LAN Threats ,
Securing Wireless Networks
4.4 Bluetooth: Introduction, User Scenario, Architecture,
protocol stack
Mobility Management
5.1 Mobility Management : Introduction, IP Mobility,
5. Optimization, IPv6 06

5.2 Macro Mobility : MIPv6, FMIPv6


5.3 Micro Mobility: CellularIP, HAWAII, HMIPv6
Long-Term Evolution (LTE) of 3GPP

6.1 Long-Term Evolution (LTE) of 3GPP : LTE System


Overview, Evolution from UMTS to LTE

6.2 LTE/SAE Requirements, SAE Architecture


6. 07
6.3 EPS: Evolved Packet System, E-UTRAN, Voice over LTE
(VoLTE), Introduction to LTE-Advanced

6.4 Self Organizing Network (SON-LTE), SON for


Heterogeneous Networks (HetNet), Comparison between
Different Generations (2G, 3G, 4G and 5G), Introduction to 5G

viii
SɅRɅSWɅTI
Department of Computer College of
Engineering Engineering
SɅRɅSWɅTI

Course Objective's
The course aims:

1. To learn the mobile computing tools and software for implementation.

2. To understand the security algorithms in mobile networks

3. To learn security concepts

4. To distinguish between different protocols used in mobile computing and applications based
on it.

5. To study main aspect of mobile computing i.e., mobility in detail.

6. To determine or provide an opportunity for students to understand the key components and
technologies involved and to gain hands-on experiences in building mobile applications.

Course Outcomes

After completing this course, students will be able to:

1. Develop and demonstrate mobile applications using various tools

2. Articulate the knowledge of GSM, CDMA & Bluetooth technologies and demonstrate it.

3. Students will able to carry out simulation of frequency reuse, hidden/exposed terminal
problem

4. Implement security algorithms for mobile communication network

5. Demonstrate simulation and compare the performance of Wireless LAN.

6. Apply the knowledge of mobility on communication. apply appropriate techniques for


mobility management.

ix
SɅRɅSWɅTI
Department of Computer College of
Engineering Engineering
SɅRɅSWɅTI

CO-PO & PSO CORELATION MATRIX

PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2

CO1 2 1 2

CO2 2

CO3 2 1 2 2

CO4 2 1 2

CO5 2 1 2 2

CO6 2 1 2

COURSE
CODE: 2 1 2 2 2 2
CSL7012

1 LOWLY CORELATED
2 MODERATELY CORELATED
3 HIGHLY CORELATED

x
SɅRɅSWɅTI
Department of Computer College of
Engineering Engineering
SɅRɅSWɅTI

LIST OF EXPERIMENT'S

Expt. Name of the Experiment Page


No. No.
1. Implementation a Bluetooth network with application as transfer of a file 1
from one device to another.
2. To implement a basic function of Code Division Multiple Access (CDMA). 11

3. Implementation of GSM security algorithms (A3/A5/A8) 20


4. Develop an application that uses GUI components. 25
5. Write an application that draws basic graphical primitives on the screen. 37
6. Develop a native application that uses GPS location information. 44

7. Implement an application that creates an alert upon receiving a message. 52


8. Develop an application that makes use of database. 58
9. Implementation of income tax/loan EMI calculator and deploy the same on 66
real devices (Implementation of any real time application)
10. Illustration of Hidden Terminal/Exposed terminal Problem. 73
11. Content Beyond Syllabus 85

xi
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

EXPERIMENT NO- 1

Title: Implementation of Bluetooth Network with application as transfer of a file


from one device to another.

1
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

CO-PO & PSO CO-RELATION MATRIX

CO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2

CO1 2 1 2

2
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

Experiment 1

AIM: Implementation of Bluetooth Network with application as transfer of a file from one
device to another.
RESOURCES REQUIRED: Android Studio, Java JDK.

THEORY:

Bluetooth is a short-range wireless technology standard that is used for exchanging data
between fixed and mobile devices over short distances using UHF radio waves in the ISM
bands, from 2.402 to 2.48 GHz, and building personal area networks (PANs). It is
mainly used as an alternative to wire connections, to exchange files between nearby portable
devices and connect cell phones and music players with wireless headphones. In the most
widely used mode, transmission power is limited to 2.5 milliwatts, giving it a very short range
of up to 10 metres (33 ft).

Features of Bluetooth:

 Send or receive files via Bluetooth


 Transfer apps
 View shared files/folders of other devices
 Create/Delete folders/files
 View log of all FTP transactions done.

IMPLEMENTATION:

Step 1: Open Android Studio. Inside it click on Open and select the file where you have saved
the code.

3
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

Step 2: Go to File select Setting and search Android SDK and download any versionof SDK as
per your requirements.

4
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

Step 3: Click on AVD Manager and create a Virtual Machine.

Step 4: While creating a virtual machine, select a pixel as per your needs. As shown in below
snapshot I have selected Pixel 3 and went to next step. Also choose which device you want that
is in which category you want the Emulator screen.

5
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

Step 5: Now you have to select a System Image and download the required packagesfor that
image. I have choosen R as a System image and have already downloaded.

6
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

Step 6: In the next step the default name is given to the virtual machine. If you want to
change the name you can change and finish creating the Virtual machine setup.

Step 7: Now you can run the virtual machine. Similarly you have to create another virtual
machine so that we can transfer one file from one virtual machine to another virtual machine
via Bluetooth transfer.

7
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

Step 8: Now we can transfer the files from one device to another device.

8
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
CONCLUSION: Hence we have successfully implemented the Bluetooth transferusing
Android Studio.

MCQS/ VIVA QUESTIONS :

1) Which of Q1. The following usually stores all user-related data that is also relevant to GSM
mobile systems?

Option A: VLR

Option B: HMR
Option C: CMR
Option D: SIM

Q2. Which of these is required for the transmission of digital information by translating
it into analogue signals via a particular frequency?
Option A: BSPK
Option B: QPSK
Option C: Modulation
Option D: Demodulation

Q3. Two or more antennas can also be combined to improve reception by counteracting
the negative effects of multi-path propagation. These antennas, also called
Option A: Multi-element antenna arrays
Option B: Smart antennas
Option C: Sectorized antenna
Option D: Isotropic radiator

Q4. In which one of the following, the slow and fast hopping is used?
Option A: GSM
Option B: GPRS
Option C: FHSS
Option D: None of the above

Q5. Which of the following does not come under subsystem of GSM architecture?
Option A: BSS
Option B: NSS
Option C: OSS
Option D: Channel

9
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

REFERENCES :

1. https://nptel.ac.in/courses/106/106/106106147/

2. https://www.coursera.org/learn/smart-device-mobile-emerging-technologies

10
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

EXPERIMENT NO- 2

Title: implement a basic function of Code Division Multiple Access (CDMA).

11
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

CO-PO & PSO CO-RELATION MATRIX

CO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2

CO 3 2 1 2

12
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
Experiment 2

AIM: To implement a basic function of Code Division Multiple Access (CDMA).

RESOURCES REQUIRED: Java, Command Prompt.

THEORY:

CDMA is a channelization protocol for Multiple Access, where information can be sent
simultaneously through several transmitters over a single communication channel. It is
achieved in below steps:
 A signal is generated which extends over a wide bandwidth.
 The code which performs this action is called spreading code.
 Later on, a specific signal can be selected with a given code even in the
presence of many other signals.
It is mainly used in mobile networks like 2G and 3G.

Procedure:

1) The station encodes its data bit as follows.


+1 if bit = 1

 -1 if bit = 0
 no signal(interpreted as 0) if station is idle
2) Each station is assigned a unique orthogonal sequence (code) which is N bit longfor
N stations.
3) Each station does a scalar multiplication of its encoded data bit and code sequence.
4) The resulting sequence is then placed on the channel.
5) Since the channel is common, amplitudes add up and hence resultant channel
sequence is sum of sequences from all channels.
6) If station 1 wants to listen to station 2, it multiplies (inner product) the channel
sequence with code of station S2.
7) The inner product is then divided by N to get data bit transmitted from station 2.

How Does CDMA Work?

CDMA allows up to 61 concurrent users in a 1.2288 MHz channel by processing eachvoice


packet with two PN codes. There are 64 Walsh codes available to differentiate between

13
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
calls and theoretical limits. Operational limits and quality issues will reduce the maximum
number of calls somewhat lower than this value.
In fact, many different "signals" baseband with different spreading codes can
be modulated on the same carrier to allow many different users to be supported. Using
different orthogonal codes, interference between the signals is minimal. Conversely, when
signals are received from several mobile stations, the base station is capable of isolating
each as they have different orthogonal spreading codes.
The following figure shows the technicality of the CDMA system. During the
propagation, we mixed the signals of all users, but by that you use the same code as the
code that was used at the time of sending the receiving side. You can take out only the
signal of each user.

Advantages of CDMA:

CDMA requires a tight power control, as it suffers from near-far effect. In other words, a
user near the base station transmitting with the same power will drown the signal latter.
All signals must have more or less equal power at the receiver

Disadvantages of CDMA:

The code length must be carefully selected. A large code length can induce delay or may
cause interference.

14
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

IMPLEMENTATION:
// Java code illustrating a simple implementation of CDMA
import java.util.*;
public class CDMA
{ private int[][]
wtable;private
int[][] copy;
private int[] channel_sequence;
public void setUp(int[] data, int num_stations)
{
wtable = new
int[num_stations][num_stations];copy = new
int[num_stations][num_stations];

buildWalshTable(num_stations, 0, num_stations - 1, 0,
num_stations - 1,
false);showWalshTable(num_stations);
for (int i = 0; i < num_stations; i++)
{ for (int j = 0; j < num_stations;
j++) {

// Making a copy of walsh table


// to be used later
copy[i][j] =
wtable[i][j];

// each row in table is code for one station.


// So we multiply each row with station
datawtable[i][j] *= data[i];
}
}

channel_sequence = new int[num_stations];


for (int i = 0; i < num_stations; i++) {
for (int j = 0; j < num_stations; j++) {
// Adding all sequences to get channel sequence
channel_sequence[i] += wtable[j][i];
}
}
}
public void listenTo(int sourceStation, int num_stations)
{
int innerProduct = 0;
for (int i = 0; i < num_stations; i++) {

15
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
// multiply channel sequence and source station code innerProduct
+= copy[sourceStation][i] * channel_sequence[i];
}

System.out.println("The data received is: "


+(innerProduct / num_stations));
}
public int buildWalshTable(int len, int i1, int i2, int j1,
int j2, boolean isBar)
{
// len = size of matrix. (i1, j1), (i2, j2) are
// starting and ending indices of wtable.
// isBar represents whether we want to add simple entry
// or complement(southeast submatrix) to wtable.
if (len == 2) {
if (!isBar) {
wtable[i1][j1]
= 1;
wtable[i1][j2] = 1;
wtable[i2][j1] = 1;
wtable[i2][j2] = -1;
}
else {
wtable[i1][j1] = -1;
wtable[i1][j2] = -1;
wtable[i2][j1] = -1;
wtable[i2][j2] = +1;
}
return 0;
}

int midi = (i1 + i2)


/ 2;int midj = (j1 +
j2) / 2;
buildWalshTable(len / 2, i1, midi, j1, midj, isBar);
buildWalshTable(len / 2, i1, midi, midj + 1, j2,
isBar);buildWalshTable(len / 2, midi + 1, i2, j1, midj,
isBar);

buildWalshTable(len / 2, midi + 1, i2, midj + 1, j2, !isBar);

return 0;
}
public void showWalshTable(int num_stations)

16
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
{
System.out.print("\n");
for (int i = 0; i < num_stations; i++)
{ for (int j = 0; j < num_stations;
j++) {
System.out.print(wtable[i][j] + " ");
}
System.out.print("\n");
}
System.out.println(" ------------------------- ");
System.out.print("\n");
}
// Driver Code
public static void main(String[] args)
{
int num_stations = 4;

int[] data = new int[num_stations];

//data bits corresponding to each


stationdata[0] = -1;
data[1] = -1;
data[2] = 0;
data[3] = 1;

CDMA channel = new CDMA();


channel.setUp(data,
num_stations);

// station you want to listen


toint sourceStation = 3;
channel.listenTo(sourceStation, num_stations);
}
}

OUTPUT:

17
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

CONCLUSION: Hence we have successfully implemented Code Division MultipleAccess


(CDMA).

MCQS/ VIVA QUESTIONS :


Q1. Changing VLRs with uninterrupted availability of all services is called as
Option A: VLR switching
Option B: Roaming
Option C: Hard handoff
Option D: Soft handoff

Q2. What is the interface between SGSN and HLR in a GPRS network structure?
Option A: Gs
Option B: Gn
Option C: Gb
Option D: Gr

Q3. UMTS is also known as ___________


Option A: IS-95
Option B: GPRS
Option C: CdmaOne
Option D: W-CDMA

Q4. It is defined as the process of transferring a call (or data transfer) in progress from
one channel to another channel.
Option A: Handover

18
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
Option B: Handoff
Option C: Roaming
Option D: Both A and B

Q5. The security algorithms used in GSM are__________.


Option A: A3
Option B: A5
Option C: A8
Option D: All of the above

REFERENCES :

1. https://nptel.ac.in/courses/106/106/106106147/

2. https://www.coursera.org/learn/smart-device-mobile-emerging-technologies

19
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

EXPERIMENT NO- 3

Title: Implementation of GSM Security Algorithm (A3/A5/A8).

20
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

CO-PO & PSO CO-RELATION MATRIX

CO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2

CO 3 2 1 2 2

21
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

EXPERIMENT NO: 03
AIM: Implementation of GSM Security Algorithm(A3/A5/A8).

RESOURCES REQUIRED: Visual Studio Code.

THEORY:

GSM (Global System for Mobile Communication):

In the World, the GSM (Global System for Mobile Communication) is the widely used cellular
standard. Due to the increase in its users the GSM network is facing several security
vulnerabilities. The GSM is made secured by using several algorithms. The algorithm used are
A3, A5, and A8 algorithms, Algorithm A3 is used for authentication, A5 is used for encryption,
and A8 is used for the generation of a cipher key.
The subscriber needs to be authenticated before he can use the services provided by the GSM.
The Authentication is based on the SIM, that stores the authentication key Ki, User
identification IMSI and the A3 Algorithm.
In the World, the GSM (Global System for Mobile Communication) is the widely used cellular
standard. Due to the increase in its users the GSM network is facing several security
vulnerabilities. The GSM is made secured by using several algorithms. The algorithm used are
A3, A5, and A8 algorithms, Algorithm A3 is used for authentication, A5 is used for encryption,
and A8 is used for the generation of a cipher key.
The subscriber needs to be authenticated before he can use the services provided by the GSM.
The Authentication is based on the SIM, that stores the authentication key Ki, User
identification IMSI and the A3 Algorithm.

IMPLEMENTATION:

import random
k=random.getrandbits(128)
m=random.getrandbits(128)
kb=bin(k)[2:]

mb=bin(m)[2:]
kbl=kb[0:64] kbr=kb[64:]
mbl=mb[0:64]

22
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
mbr=mb[64:]
a1=int(kbl,2)^int(mbr,2)
a2=int(kbr,2)^int(mbl,2)
a3=a1^a2
a4=bin(a3)[2:].zfill(64)

a5=a4[0:32]
a6=a4[32:]

a7=int(a5,2)^int(a6,2)
print("128 Bit Key = ",kb)

print("128 Random Bits Generated = ",mb)


print("RES/SRES = ",bin(a7)[2:].zfill(len(a5)))

OUTPUT:

CONCLUSION: Hence we have successfully implemented GSM Security Algorithm.

MCQS/ VIVA QUESTIONS :


Q1. ________________ is the mechanism of taking a packet consisting of packet header
and data and putting it into the data part of a new packet.
Option A: Decapsulation
Option B: Encapsulation
Option C: IP-in-IP

23
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
Option D: Packet extension

Q2. Foreign agents and home agents advertise their presence


periodically using special message is called as
Option A: Tunneling message
Option B: Registration request
Option C: Agent advertisement message
Option D: Binding request

Q3. In TCP/IP, ———————— is a congestion control algorithm that makes it


possible to quickly recover lost data packets.
Option A: Fast retransmit and fast recovery
Option B: Fast retransmit
Option C: Fast recovery
Option D: None of the above

Q4. In the Indirect TCP the Foreign Agent (FA) becomes or acts as a —— and relays
data in both directions
Option A: Router
Option B: Node
Option C: Proxy
Option D: Access Point

REFERENCES :

1. https://nptel.ac.in/courses/106/106/106106147/

2. https://www.coursera.org/learn/smart-device-mobile-emerging-technologies

24
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

EXPERIMENT NO- 4

Title: Develop and application that uses GUI components (Registration Form).

25
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

CO-PO & PSO CO-RELATION MATRIX

CO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2

CO3 2 1 2 2

26
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

EXPERIMENT NO: 4
AIM: Develop and application that uses GUI components (Registration Form).
REQUIREMENT: Windows 10, Visual Studio, Java IDE.
THEORY:
Swing is a part of the JFC (Java Foundation Classes). Building Graphical User Interface in
Java requires the use of Swings. Swing Framework contains a large set of components which
allow a high level of customization and provide rich functionalities, and is used to create
window-based applications. Java swing components are lightweight, platform-independent,
provide powerful components liketables, scroll panels, buttons, list, colour chooser, etc.
we’ll see how to make a Registration form which includes all the buttons and field in one
Form.
Steps:
1) Create a Java file that contains the main class – Registration. This class will onlycontain
the main method to invoke the required methods.
class Registration {
public static void main(String[] args)
throws Exception{
MyFrame f = new MyFrame();
}}
2) Create another class MyFrame, which will contain the form.
3) In this MyFrame Class, the methods to be made are: Components like JLabel, JTextField,
JRadioButton, ButtonGroup, JComboBox, and JTextArea. These components will
collectively form the Registration form. A constructor, to initialize the components with
default values. A method actionPerformed() to get the action performed by the user and act
accordingly.
4) Copy the code of MyFrame class from below.
5) Save the file as Registration.java
6) Compile the file by using javac command.
javac Registration.java
7) Run the program by calling the main class
java Registration

27
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
IMPLEMENTATION:
import javax.swing.*;
import java.awt.*; import
java.awt.event.*;class
MyFrame
extends JFrame implements
ActionListener {
// Components of the Form
private Container c; private
JLabel title; private JLabel
name; private JTextField
tname;

private JLabel mno;


private JTextField tmno;
private JLabel gender;
private JRadioButton male;
private JRadioButton female;
private ButtonGroup gengp;
private JLabel dob;
private JComboBox date;
private JComboBox month;
private JComboBox year;
private JLabel add;
private JTextArea tadd;
private JCheckBox term;
private JButton sub;
private JButton reset;

28
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
private JTextArea tout;
private JLabel res;
private JTextArea resadd;

private String dates[]


= { "1", "2", "3", "4", "5",
"6", "7", "8", "9", "10",
"11", "12", "13", "14", "15",
"16", "17", "18", "19", "20",
"21", "22", "23", "24", "25",
"26", "27", "28", "29", "30",
"31" };
private String months[]
= { "Jan", "Feb", "Mar", "Apr",
"May", "Jun", "July", "Aug",
"Sup", "Oct", "Nov", "Dec" };
private String years[]
= { "1995", "1996", "1997", "1998",
"1999", "2000", "2001", "2002",
"2003", "2004", "2005", "2006",
"2007", "2008", "2009", "2010",
"2011", "2012", "2013", "2014",
"2015", "2016", "2017", "2018",
"2019","2020","2021" };
// constructor, to initialize the components
// with default values.
public MyFrame()
{
setTitle("Registration Form");
setBounds(300, 90, 900, 600);

29
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
setDefaultCloseOperation(EXIT_ON_CLOSE);
setResizable(false);
c = getContentPane();
c.setLayout(null);
title = new JLabel("REGISTRATION FORM");
title.setFont(new Font("Times New Roman", Font.BOLD |
Font.ITALIC, 26));
title.setSize(300, 20);
title.setLocation(300, 40);
c.add(title);
name = new JLabel("NAME");
name.setFont(new Font("Times New Roman", Font.BOLD, 16));
name.setSize(100, 20);
name.setLocation(100, 100);
c.add(name);
tname = new JTextField();
tname.setFont(new Font("Times New Roman", Font.PLAIN, 12));
tname.setSize(200, 30);
tname.setLocation(200, 100);
c.add(tname);
mno = new JLabel("MOBILE NO");
mno.setFont(new Font("Times New Roman", Font.BOLD, 16));
mno.setSize(100, 20);
mno.setLocation(100, 150);
c.add(mno);
tmno = new JTextField();
tmno.setFont(new Font("Times New Roman", Font.PLAIN, 12));tmno.setSize(200,
30);
tmno.setLocation(200, 150);
c.add(tmno);
30
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
gender = new JLabel("GENDER");
gender.setFont(new Font("Times New Roman", Font.BOLD, 16));
gender.setSize(100, 20);
gender.setLocation(100, 200);
c.add(gender);
male = new JRadioButton("Male");
male.setFont(new Font("Times New Roman", Font.BOLD, 12));
male.setSelected(true);
male.setSize(75, 20);
male.setLocation(200, 200);
c.add(male);
female = new JRadioButton("Female");
female.setFont(new Font("Times New Roman", Font.BOLD, 15));
female.setSelected(false);
female.setSize(80, 20);
female.setLocation(275, 200);
c.add(female);
gengp = new ButtonGroup();
gengp.add(male);
gengp.add(female);
dob = new JLabel("DATE OF BIRTH");
dob.setFont(new Font("Times New Roman", Font.BOLD, 16));dob.setSize(100,
20);
dob.setLocation(100, 250);
c.add(dob);
date = new JComboBox(dates);
date.setFont(new Font("Times New Roman", Font.PLAIN, 15));
date.setSize(50, 20);

31
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
date.setLocation(200, 250);
c.add(date);
month = new JComboBox(months);
month.setFont(new Font("Times New Roman", Font.PLAIN, 15));month.setSize(60,
20);
month.setLocation(250, 250);
c.add(month);
year = new JComboBox(years);
year.setFont(new Font("Times New Roman", Font.PLAIN, 15));year.setSize(60,
20);
year.setLocation(320, 250);
c.add(year);
add = new JLabel("ADDRESS");
add.setFont(new Font("Times New Roman", Font.BOLD, 16));
add.setSize(100, 40);
add.setLocation(100, 300);
c.add(add);
tadd = new JTextArea();
tadd.setFont(new Font("Times New Roman", Font.PLAIN, 15));
tadd.setSize(200, 75);
tadd.setLocation(200, 300);
c.add(tadd);
term = new JCheckBox("Accept Terms And Conditions.");
term.setFont(new Font("Times New Roman", Font.PLAIN, 15));
term.setSize(250, 20);
term.setLocation(150, 400);
c.add(term);
sub = new JButton("SUBMIT");
sub.setFont(new Font("Times New Roman", Font.BOLD, 15));sub.setSize(100,
30);

32
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
sub.setLocation(100, 450);
sub.addActionListener(this);
c.add(sub);
reset = new JButton("RESET");
reset.setFont(new Font("Times New Roman", Font.BOLD, 15));
reset.setSize(100, 30);
reset.setLocation(350, 450);
reset.addActionListener(this);c.add(reset);
tout = new JTextArea();
tout.setFont(new Font("Times New Roman", Font.PLAIN, 16));
tout.setSize(300, 400);
tout.setLocation(500, 100);
tout.setLineWrap(true);
tout.setEditable(false);
c.add(tout);
res = new JLabel("");
res.setFont(new Font("Times New Roman", Font.PLAIN, 20));res.setSize(500,
25);
res.setLocation(100, 500);
c.add(res);
resadd = new JTextArea();
resadd.setFont(new Font("Times New Roman", Font.PLAIN, 15));
resadd.setSize(200, 75);
resadd.setLocation(580, 175);
resadd.setLineWrap(true);
c.add(resadd); setVisible(true);
}
// method actionPerformed()
// to get the action performed
// by the user and act accordingly
public void actionPerformed(ActionEvent e)
33
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
{
if (e.getSource() == sub) {if
(term.isSelected()) {
String data1;
String data = "Name : " + tname.getText() + "\n" + "Mobile : " +
tmno.getText() + "\n";
if (male.isSelected())
data1 = "Gender : Male"+ "\n";
else
data1 = "Gender : Female"+ "\n";
String data2 = "DOB : "+ (String)date.getSelectedItem()+ "/" +
(String)month.getSelectedItem()+ "/" + (String)year.getSelectedItem()+ "\n";
String data3 = "Address : " + tadd.getText();
tout.setText(data + data1 + data2 + data3);
tout.setEditable(false);
res.setText("REGISTRATION SUCCESSFULLY .......... ");
}
else {
tout.setText("");
resadd.setText("");
res.setText("Please accept the" + " terms & conditions..");
}
}
else if (e.getSource() == reset) {
String def = "";
tname.setText(def);
tadd.setText(def);
tmno.setText(def);
res.setText(def);
tout.setText(def);

34
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
term.setSelected(false);
date.setSelectedIndex(0);
month.setSelectedIndex(0);
year.setSelectedIndex(0);
resadd.setText(def);
}
}
}
// Driver Code class
Registration {
public static void main(String[] args) throws Exception
{
MyFrame f = new MyFrame();
}
}

MCQS/ VIVA QUESTIONS :


Q1. A mobile phone uses ______ type of duplex communication
Option A: Full
Option B: Half
Option C: Both A And B
Option D: None of the above

Q2. What does LTE stand for


Option A: Level telecom advanced
Option B: Long terminal advanced
Option C: Long term evolution
Option D: Long time evolution

Q3. What are the advantages of a 4G LTE network over 3G network?


Option A: More Spectral Efficiency
Option B: Low power consumption
Option C: Scalability and flexibility with other networks
Option D: All of the above

35
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
Q4. What is Spring MVC?

Ans – The MVC stands for Model-View-Controller, which is its core function, allowing separation of the
business logic, presentation logic, and navigation logic.

Q5. What is a JPA repository?

Ans – The Java Persistence API (JPA) is the standard way of persisting Java objects into relational
databases.

REFERENCES :

1. https://nptel.ac.in/courses/106/106/106106147/

2. https://www.coursera.org/learn/smart-device-mobile-emerging-technologies

36
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

EXPERIMENT NO- 5

Title: To implement a Paint Application in Java.

37
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

CO-PO & PSO CO-RELATION MATRIX

CO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2

CO3 2 1 2 2

38
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

EXPERIMENT NO- 5
AIM: To implement a Paint Application in Java.

RESOURCES REQUIRED: Visual Studio, java IDE.

THEORY:

AWT:

AWT stands for Abstract window toolkit is an Application programming interface (API) for
creating Graphical User Interface (GUI) in Java. It allows Java programmers to develop
window-based applications.
AWT provides various components like button, label, checkbox, etc. used as objects inside a
Java Program. AWT components use the resources of the operating system, i.e., they are
platform-dependent, which means, component's view can be changed according to the view of
the operating system. The classes for AWT are provided by the Java.awt package for various

AWT components. The following image represents the hierarchy for Java AWT.

39
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

Component Class:

The component class stands at the top of the AWT hierarchy, is an abstract class thatcontains all
the properties of the component visible on the screen. The Component object contains
information about the currently selected foreground and background colour. It also has
information about the currently selected text colour.

Container:

The container is a component that contains other components like button, text field, label, etc.
However, it is a subclass of the Component class.

Panel:

The panel can be defined as a container that can be used to hold other components. However, it
doesn't contain the title bar, menu bar, or border.

Window:

A window can be defined as a container that doesn't contain any border or menu bar.It creates a
top-level view. However, we must have a frame, dialog, or another window for creating a
window.

Frame:

The frame is a subclass of Window. It can be defined as a container with components like
button, text field, label, etc. In other words, AWT applications are mostly created using frame
container.

Dialog:

The Dialog control represents a top level window with a border and a title used to take some
form of input from the user. It inherits the Window class. Unlike Frame, it doesn't have
maximize and minimize buttons.

IMPLEMENTATION:
TestDraw.java
public class TestDraw
{
public static void main( String args[] )
{

40
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
DrawFrame paintGui = new DrawFrame(); //initalize DrawFrame object calledpaintGui
} // end main
} // end class TestDraw

DrawFrame.java

public class DrawFrame extends JFrame


{
private JLabel stausLabel; //label display mouse coordinates
private DrawPanel panel; //draw panel for the shapes private
JButton undo; // button to undo last drawn shape private JButton
redo; // button to redo an undo
private JButton clear; // button to clear panel
private JComboBox colors; //combobox with color options

//array of strings containing color options for JComboBox colors


private String colorOptions[]=
{"Black","Blue","Cyan","Dark Gray","Gray","Green","Light Gray",
"Magenta","Orange","Pink","Red","White","Yellow"};

OUTPUT:

41
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

CONCLUSION: Hence we have successfully implemented paint application in java.

MCQS/ VIVA QUESTIONS :


Q1. The subclass of a java.awt.Component class is known as a ?

A. system
B. component
C. container
D. component manager

Q2. What is the super class of all components of Java?

A. java.all.Component
B. all.awt.Component
C. java.awt.Component
D. awt.Component

42
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

Q3. The subclass of a java.awt.Container class is known as a container.


A. TRUE
B. FALSE
C. Can be true or false
D. Can not say

Q4. How many layout managers defined in java.awt package?

A. 2
B. 3
C. 4
D. 5

Q5. A ___________ dictates the style of arranging the components in a container.

A. border layout
B. grid layout
C. panel
D. layout manager

REFERENCES :

1. https://nptel.ac.in/courses/106/106/106106147/

2. https://www.coursera.org/learn/smart-device-mobile-emerging-technologies

43
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

EXPERIMENT NO- 6

Title: To implement a basic function of Global Positioning System (GPS).

44
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

CO-PO & PSO CO-RELATION MATRIX

CO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2

CO3 2 1 2 2

45
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
EXPERIMENT NO- 6

AIM: To implement a basic function of Global Positioning System (GPS).

RESOURCES REQUIRED: Android Studio.

THEORY:

Global Positioning System:

GPS is a satellite-based navigation system. It provides time and location-based information to a


GPS receiver, located anywhere on or near the earth surface. GPS works in all weather
conditions, provided there is an unobstructed line of sight communication with 4 or more GPS
satellites. GPS is managed by the US Air Force.
A GPS operates independently of the user’s internet connection or telephone signal. However,
their presence increases the effectiveness of GPS positioning. GPS was initially developed by
the US government for military purpose, but currently, anyone with a GPS receiver can receive
radio signals from GPS satellites.
Initially when GPS was developed for military use, there were 24 GPS satellites
orbiting the earth every 12 hours at a height of 20, 180 km.
4 GPS satellites were located in each of the 6 orbits with 60 degree orientationbetween
each other. These orbital planes do not rotate with respect to any star.
Later, the number of satellites were increased to 32, to improve location
accuracy.
Localization of any GPS receiver is done through time of flight measurement.
The greater the number of satellite in line of sight to a GPS receiver, the greateris the
accuracy in determining the position of the receiver.

Working of GPS:

Any instant of time, there are at least 4 GPS satellites in line of sight to a receiver on the earth.
Each of these GPS satellites sends information about its position and the current time to the
GPS receiver at fixed regular instants of time. This information is transmitted to the receiver in
the form of signal which is then intercepted by the receiver devices. These signals are radio
signals that travel with the speed of light. The distance between a GPS receiver and the satellite
is calculated by finding the difference between the time the signal was sent from GPS satellite
and the time the GPS receiver received the signal.
Once the receiver receives the signal from at least three satellites, the receiver then points its
location using trilateration process. A GPS requires at least 3 satellites to calculate 2-D
position(latitude and longitude on a map). In this case, the GPS receiver assumes that it is
located at mean sea level. However, it requires at least 4 satellites to find receivers 3-D
position(latitude, longitude, and altitude).

46
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

Trilateration:

Trilateration is the process of determining your position based on the intersection of spheres.
When a receiver receives a signal from one of the satellite, it calculates its distance from the
satellite considering a 3-D sphere with the satellite located at the center of the sphere. Once
the receiver does the same with 3 other GPS satellites, the receiver then proceeds to find the
intersection point of the 3 spheres to calculate it’s location. Once the position of a receiver is
calculated, the GPS device can then easilycalculate:
Time of sunrise and sunset
Speed
Track
distance to destination of the GPS receiver.

Technical challenges face by GPS:

Time synchronization between individual satellites and the GPS receiver


Real time update of the exact location of the GPS satellite
Precise measurement of time of flight
Interference with other signals

IMPLEMENTATION:

package com.yayandroid.locationmanager.sample;import
android.content.Intent;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.Nullable;

import androidx.appcompat.app.AppCompatActivity;

import com.yayandroid.locationmanager.sample.activity.SampleActivity;

import com.yayandroid.locationmanager.sample.fragment.SampleFragmentActivity; import


com.yayandroid.locationmanager.sample.service.SampleServiceActivity;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

47
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
}
public void inActivityClick(View view) {
startActivity(new Intent(this, SampleActivity.class));
}

public void inFragmentClick(View view) {

startActivity(new Intent(this, SampleFragmentActivity.class));

public void inServiceClick(View view) {

startActivity(new Intent(this, SampleServiceActivity.class));

OUTPUT:

The location for Sample in Activity, Sample in Fragment and Sample in Service is same and
the location address is being captured in phone for getting the actual location address.

48
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

49
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

CONCLUSION: Hence we have successfully implemented the GPS program inAndroid


Studio.
MCQS/ VIVA QUESTIONS :
Q1. During which year the project on GPS was launched?

A. 1970

B. 1971

C. 1972

D. 1973

Q2. ___________ is present on the satellites of GPS to contribute the accurate time information.

A. Antenna

B. Transponder

50
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
C. Atomic clock

D. All the above

Q3. How many minimum satellites are operational in the constellation of GPS?

A. 24

B. 25

C. 26

D. 27

Q4. The GPS operated by Indians is ____________.

A. Compass

B. GLONASS

C. Galileo

D. NavIC

Q5. Once the Selective Availability got lifted the accuracy of GPS was for __________ meters.

A. 3

B. 4

C. 5

D. 6

REFERENCES :

1. https://nptel.ac.in/courses/106/106/106106147/

2. https://www.coursera.org/learn/smart-device-mobile-emerging-technologies

51
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

EXPERIMENT NO- 7

Title: To implement a basic function of Android Notification.

52
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

CO-PO & PSO CO-RELATION MATRIX

CO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2

CO3,CO4,CO5 2 1 2 2 2

53
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

EXPERIMENT NO: 07
AIM: To implement a basic function of Android Notification.

RESOURCES REQUIRED: Android Studio.

THEORY:

Android Notification:

A notification is a message you can display to the user outside of your application's normal UI.
When you tell the system to issue a notification, it first appears as an icon in the notification
area. To see the details of the notification, the user opens the notification drawer. Both the
notification area and the notification drawer are system- controlled areas that the user can view
at any time.
Android Notification provides short, timely information about the action happened in the
application, even it is not running. The notification displays the icon, title and some amount of
the content text.

Set Android Notification Properties:

The properties are set using NotificationCompat.Builder object. Some of the notification
properties are mention below:

 setSmallIcon(): It sets the icon of notification.


 setContentTitle(): It is used to set the title of notification.
 setContentText(): It is used to set the text message.
 setAutoCancel(): It sets the cancelable property of notification.
 setPriority(): It sets the priority of notification.

IMPLEMENTATION:

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fernando.basicnotification">
<application
android:name=".App"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"

54
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
android:supportsRtl="true"
android:theme="@style/Theme.BasicNotification">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application></manifest>

OUTPUT:

55
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

CONCLUSION: Hence we have successfully implemented the Android Notificationprogram in


Android Studio.
MCQS/ VIVA QUESTIONS :

Q1. Under which of the following Android is licensed?

a. OSS
b. Sourceforge

56
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

c. Apache/MIT
d. None of the above

Q2. Which of the following virtual machine is used by the Android operating system?

a. JVM
b. Dalvik virtual machine
c. Simple virtual machine
d. None of the above

Q3. How can we stop the services in android?

a. By using the stopSelf() and stopService() method


b. By using the finish() method
c. By using system.exit() method
d. None of the above

Q4. On which of the following, developers can test the application, during developing the android
applications?

a. Third-party emulators
b. Emulator included in Android SDK
c. Physical android phone
d. All of the above

Q5. Which of the following is not an activity lifecycle callback method?

a. onClick() method
b. onCreate() method
c. onStart() method
d. onBackPressed() method

REFERENCES :

1. https://nptel.ac.in/courses/106/106/106106147/

2. https://www.coursera.org/learn/smart-device-mobile-emerging-technologies

57
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

EXPERIMENT NO- 8

Title: To implement a program in DBMS using Android Studio.

58
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

CO-PO & PSO CO-RELATION MATRIX

CO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2

CO3,CO4,CO5 2 1 2 2 2

59
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

EXPERIMENT NO: 08

AIM: To implement a program in DBMS using Android Studio.

RESOURCES REQUIRED: Android Studio.

THEORY:

What is Database?

The database is a collection of inter-related data which is used to retrieve, insert and delete the
data efficiently. It is also used to organize the data in the form of a table, schema, views, and
reports, etc. Using the database, you can easily retrieve, insert, and delete the information.
For example: The college Database organizes the data about the admin, staff, students and
faculty etc.

Database Management System:

Database management system is a software which is used to manage the database. For
example: MySQL, Oracle, etc are a very popular commercial database which is used
in different applications.
DBMS provides an interface to perform various operations like database creation,
storing data in it, updating data, creating a table in the database and a lot more.
It provides protection and security to the database. In the case of multiple users, it also
maintains data consistency.

DBMS allows users the following tasks:

Data Definition: It is used for creation, modification, and removal of definition that defines
the organization of data in the database.
Data Updation: It is used for the insertion, modification, and deletion of the actual data in the
database.
Data Retrieval: It is used to retrieve the data from the database which can be used by
applications for various purposes.
User Administration: It is used for registering and monitoring users, maintain data integrity,
enforcing data security, dealing with concurrency control, monitoring performance and
recovering information corrupted by unexpected failure.

60
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

Characteristics of DBMS:

It uses a digital repository established on a server to store and manage the


information.
It can provide a clear and logical view of the process that manipulates data.
DBMS contains automatic backup and recovery procedures.

It contains ACID properties which maintain data in a healthy state in case offailure.
It can reduce the complex relationship between data.
It is used to support manipulation and processing of data.
It is used to provide security of data.
It can view the database from different viewpoints according to therequirements
of the user.

Advantages of DBMS:

Controls database redundancy: It can control data redundancy because it stores allthe data in
one single database file and that recorded data is placed in the database.
Data sharing: In DBMS, the authorized users of an organization can share the dataamong
multiple users.
Easily Maintenance: It can be easily maintainable due to the centralized nature of thedatabase
system.
Reduce time: It reduces development time and maintenance need.

Backup: It provides backup and recovery subsystems which create automatic backupof data
from hardware and software failures and restores the data if required.
Multiple user interface: It provides different types of user interfaces like graphicaluser
interfaces, application program interfaces

IMPLEMENTATION:

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.inventory">

61
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
<application
android:name="com.example.inventory.InventoryApplication"
android:allowBackup="true" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.InventoryApp">

<activity android:name="com.example.inventory.MainActivity">

<intent-filter>

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>

</activity>

</application>

</manifest>

62
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

OUTPUT:

63
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

64
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

CONCLUSION: Hence we have successfully implemented a program in DBMS usingAndroid


Studio.
MCQS/ VIVA QUESTIONS :
Q1. Can a user save all database updates in onStop ()?
A - Yes, a user can save all database updates in onStop()
B - No, a user can save in onSavedInstance()
C - No, a user can save in a Bundle()
D - No, In some situations, a user can't reach onStop()

Q2. What is Manifest.xml in android?


A - It has information about layout in an application
B - It has the information about activities in an application
C - It has all the information about an application
D - None of the above

Q3. How to access the context in android content provider?


A - Using getContext() in onCreate()
B - Using intent()
C - Using getApplicationContext() at anywhere in an application
D-A&C

Q4. Which features are considered while creating android application?


A - Screen Size
B - Input configuration
C - Platform Version
D - All of above
Q5. Data can be read from local source XML in android through
A - XML resource parser
B - XML pull parsing
C - DOM parsing
D - None of the above

REFERENCES :
1. https://nptel.ac.in/courses/106/106/106106147/

2. https://www.coursera.org/learn/smart-device-mobile-emerging-technologies

65
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

EXPERIMENT NO- 9

Title: Write a program to implement EMI calculation using Android Studio.

66
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

CO-PO & PSO CO-RELATION MATRIX

CO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2

CO3,CO4 2 1 2 2

67
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

EXPERIMENT NO: 09

AIM: Write a program to implement EMI calculation using Android Studio.


RESOURCES REQUIRED: Android Studio.
THEORY:
Equated Monthly Instalment’s (EMI):
The Equated Monthly Instalments (EMI) of a loan depends on the three factors: Loan
amount: This stands for the total amount that has been borrowed the individual. Interest rate:
This stands for the rate at which the interest is charged on the amount borrowed. Tenure of
loan: This stands for the agreed loan repayment time-frame between the borrower and the
lender. The other major factor which determines the EMI payments is the type of interest on
the loan. In case of fixed rate loans, the EMI payments remain constant during the tenure. In
case of floating rate loans, the interestrates vary based on the prevailing market rates.
The other factor which effects the EMI payments is the pre closure or partial payments made
towards the loan. Any partial payments made towards the loan are deducted from the principal
amount of the loan. This results in reduction of total interest that is to be paid. Generally an
individual who is making a partial payment will be given an option to keep the tenure constant
or keep the EMI constant. If one opts for keeping the tenure constant, the monthly EMI
payments will be reduced.
Formula:
E = (P.r.(1+r)n) / ((1+r)n – 1)
Here,
P = loan amount i.e principal amountR
= Interest rate per month
T = Loan time period in year
IMPLEMENTATION:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.cmt.taxcalculator">
<application android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:theme="@style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">

68
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

<activity android:name=".FinalIncomeActivity"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
></activity>
<activity android:name=".NextIncome" />

<activity android:name=".MainActivity">

<intent-filter>

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>

</activity>

<activity

android:name=".IncomeActivity"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar" />

<activity android:name=".SplashScreen" />

<activity android:name=".EMIActivity" />

</application>

</manifest>

69
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

OUTPUT:

70
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

CONCLUSION: Hence we have successfully implemented the EMI program usingAndroid


Studio.

MCQS/ VIVA QUESTIONS :

Q1. What is the HTTP response error code status in android?


A - status code < 100
B - status code > 100

71
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
C - status >= 400
D - None of the above

Q2. What is the life cycle of foreground activity in android?


A - onCreate() −> onStart() −> onResume() −> onStop() −> onRestart
B - onCreate() −> onStart() −> onResume() −>onStop()
C - onCreate() −> onStart() −> onResume()
D - None of the above

Q3. Can a user save all database updates in onStop ()?


A - Yes, a user can save all database updates in onStop()
B - No, a user can save in onSavedInstance()
C - No, a user can save in a Bundle()
D - No, In some situations, a user can't reach onStop()

Q4. What is Manifest.xml in android?


A - It has information about layout in an application
B - It has the information about activities in an application
C - It has all the information about an application
D - None of the above

Q5. What is NDK?


Ans: NDK (Native Development Kit) is a toolset which enables you to implement part of Android
Application in native code using languages C or C++.

REFERENCES :

1. https://nptel.ac.in/courses/106/106/106106147/

2. https://www.coursera.org/learn/smart-device-mobile-emerging-technologies

72
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

EXPERIMENT NO- 10

Title: Implementation of Hidden Terminal Problem (NS-2).

73
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

CO-PO & PSO CO-RELATION MATRIX

CO PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2

CO3,CO4,CO5 2 2 2 2 2

74
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
Experiment 10

AIM: Implementation of Hidden Terminal Problem (NS-2).

RESOURCES REQUIRED:

THEORY:

A wireless network with lack of centralized control entity, sharing of wireless bandwidth among
network access nodes i.e. medium access control (MAC) nodes must be organized in
decentralized manner. The hidden terminal problem occurs when a terminal is visible from a
wireless access point (APs), but not from other nodes communicating with that AP. This
situation leads the difficulties in medium access control sublayer over wireless networking.
In a formal way hidden terminal are nodes in a wireless network that are out of range of other
node or a collection of nodes. Consider a wireless networking, each node at the far edge of the
access point’s range, which is known as A, can see the access point, but it is unlikely that the
same node can see a node on the opposite end of the access point’s range, C. These nodes are
known as hidden. The problem is when nodes A and C start to send packets simultaneously to
the access point B. Because the nodes A and C are out of range of each other and so cannot
detect a collision while transmitting, Carrier sense multiple access with collision detection
(CSMA/CD) does not work, and collisions occur, which then corrupt the data received by the
access point. To overcome the hidden node problem, RTS/CTS handshaking (IEEE 802.11
RTS/CTS) is implemented in conjunction with the Carrier sense multiple accesses withcollision
avoidance (CSMA/CA) scheme. The same problem exists in a MANET.
The transmission range of access point A reaches at B, but not at access point C, similarly
transmission range of access point C reaches B, but not at A. These nodes are known as hidden
terminals. The problem occurs when nodes A and C start to send data packets simultaneously to
the access point B. Because the access points A and C are out of range of each other and
resultant they cannot detect a collision while transmitting, Carrier sense multiple access with
collision detection (CSMA/CD) does not work, and collisions occur, which then corrupt the
data received by the access point B due to the hidden terminal problem.
The hidden terminal analogy is described as follows:

 Terminal A sends data to B, terminal C cannot hear A


 Terminal C wants to send data to B, terminal C senses a “free” medium (CSfails)
and starts transmitting
 Collision at B occurs, A cannot detect this collision (CD fails) and continues withits
transmission to B
 Terminal A is “hidden” from C and vice versa.

75
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

The solution of hidden terminal problem is as follows.

When A wants to send a packet to B, A first sends a Request-to-send (RTS) to B. Onreceiving


RTS, B responds by sending Clear-to-Send (CTS).
When C overhears a CTS, it keeps quiet for the duration of the transfer. Transferduration is
included in both RTS and CTS.
RTS and CTS are short frames, reduces collision chance.

IMPLEMENTATION:
https://github.com/vinaynpp/mcc BEGIN{
sim_end = 200; i=0;
while (i<=sim_end) {sec[i]=0; i+=1;};
}
{
if ($1=="r" && $7=="cbr"&& $3=="_0_") { sec[int($2)]+=$8;
};
}
END{
i=0;
while (i<=sim_end) {print i " " sec[i]; i+=1;};
}# Define options
$ns node-config -adhocRouting $val(rp) \
-llType $val(ll) \

SɅRɅSWɅTI 76
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \

-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace ON Phy/WirelessPhy set CSThresh
for {set i 0} {$i < $val(nn) } { incr i } { set node_($i) [$ns node]
}
$node_(0) set X_ $val(R)
$node_(0) set Y_ $val(R)
$node_(0) set Z_ 0
$node_(1) set X_ $val(R)
$node_(1) set Y_ 0
$node_(1) set Z_ 0
$node_(2) set X_ 0
$node_(2) set Y_ $val(R)
$node_(2) set Z_ 0
$node_(3) set X_ [expr $val(R) *2]
$node_(3) set Y_ $val(R)
$node_(3) set Z_ 0
$node_(4) set X_ $val(R)
$node_(4) set Y_ [expr $val(R) *2]
$node_(4) set Z_ 0
for {set i 0} {$i<$val(nn)} {incr i} {
$ns initial_node_pos $node_($i) 30

SɅRɅSWɅTI 77
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
}
# Generation of movements
$ns at 0 "$node_(1) setdest $val(R) $val(R) 3.0"
$ns at 0 "$node_(2) setdest $val(R) $val(R) 3.0"
$ns at 0 "$node_(3) setdest $val(R) $val(R) 3.0"
$ns at 0 "$node_(4) setdest $val(R) $val(R) 3.0"
# Set a TCP connection between node_(0) and node_(1) set tcp [new
Agent/TCP/Newreno]
#$tcp set class_ 2
set tcp [new Agent/UDP]
$tcp set class_ 2
set sink [new Agent/Null]
$ns attach-agent $node_(1) $tcp
$ns attach-agent $node_(0) $sink
$ns connect $tcp $sink
set ftp [new Application/Traffic/CBR]
$ftp attach-agent $tcp
$ns at 0.0 "$ftp start"
# ################################################
# For coloring but doesnot work
# ################################################
$tcp set fid_ 1
$ns color 1 blue #///////////////////////////////////////////////// set tcp [new Agent/UDP]
$tcp set class_ 2
set sink [new Agent/Null]
$ns attach-agent $node_(2) $tcp
$ns attach-agent $node_(0) $sink
$ns connect $tcp $sink
set ftp [new Application/Traffic/CBR]
$ftp attach-agent $tcp
$ns at 0.0 "$ftp start"
set tcp [new Agent/UDP]

SɅRɅSWɅTI 78
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
$tcp set class_ 2
set sink [new Agent/Null]
$ns attach-agent $node_(3) $tcp
$ns attach-agent $node_(0) $sink
$ns connect $tcp $sink
set ftp [new Application/Traffic/CBR]
$ftp attach-agent $tcp
$ns at 0.0 "$ftp start"
set tcp [new Agent/UDP]
$tcp set class_ 2
set sink [new Agent/Null]
$ns attach-agent $node_(4) $tcp
$ns attach-agent $node_(0) $sink
$ns connect $tcp $sink
set ftp [new Application/Traffic/CBR]
$ftp attach-agent $tcp
$ns at 0.0 "$ftp start"
# Telling nodes when the simulation ends #for {set i 0} {$i < $val(nn) } { incr i } { #
$ns at $val(stop) "$node_($i) reset"; #}

OUTPUT:

SɅRɅSWɅTI 79
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

SɅRɅSWɅTI 80
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

SɅRɅSWɅTI 81
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

CONCLUSION: Thus, we have performed the experiment of and illustrated the hidden
terminal problem using NS2 and properly explained the same which helps to understand
better.
82 8 2
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

MCQS/ VIVA QUESTIONS :

Q1. A___________ sensing system is inherently more robust against individual sensor node
or link failures, because of redundancy in the network

A. centralized
B. decentralized
C. ad-hoc
D. multi hope

Q2. Sensors can be used

A. to monitor conditions and movements of wild animals or plants in wildlife habitats


B. to monitor air quality and track environmental pollutants, wildfires or other natural or man-
made disasters
C. to monitor biological or chemical hazards to provide early warnings
D. all of above

Q3. Wireless networks are computer networks that use radio frequency channels as their __ for
communication.

A. physical medium
B. medium access control
C. tdma
D. cdma

Q4. in S-MAC is similar to the using an RTS/CTS exchange

A. collision avoidance
B. overhearing avoidance
C. both
D. one of above

Q5. This version is time scheduled. A central controller in the network assigns a fixed
transmission order

83 8 3
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
A. 1-persistent csma
B. non-persistent csma
C. p-persistent csma
D. o-persistent csma

REFERENCES :

1. https://nptel.ac.in/courses/106/106/106106147/

2. https://www.coursera.org/learn/smart-device-mobile-emerging-technologies

84 8 4
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI

Content beyond Syllabus

85 8 5
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
Telephony Manager

Class to determine telephony services and states


- IDLE, RINGING, DATA_CONNECTED…

App can register to receive notifications of state changes.

Some telephony information needs permissions to be set in the manifest:

<uses-permission android:name="android.permission.READ_PHONE_STATE” />

Example

Main.xml

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout

xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">

<TextView
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:text="Telephony Manager Demo"android:textSize="22sp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"android:id="@+id/text1"
android:text="Result"></TextView>

</LinearLayout>
Manifest

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.manish.telephony"

android:versionCode="1"

android:versionName="1.0" >
86 8 6
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
<uses-sdk android:minSdkVersion="15" />

<uses-permission android:name="android.permission.READ_PHONE_STATE" />


<application
android:icon="@drawable/ic_launcher"android:label="@string/app_name" >

<activity
android:label="@string/app_name"

android:name=".TelephonyManagerDemoActivity" >

<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
import android.app.Activity;

import android.content.Context;

import android.os.Bundle;

import android.telephony.PhoneStateListener;

import android.telephony.TelephonyManager;

import android.widget.TextView;

public class TelephonyManagerDemoActivity extends Activity { TextView textView;

TelephonyManager telephonyManager; PhoneStateListener listener;

/** Called when the activity is first created. */ @Override

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);


setContentView(R.layout.main);

textView = (TextView) findViewById(R.id.text1);

// Get the telephony manager telephonyManager = (TelephonyManager)

getSystemService(Context.TELEPHONY_SERVICE);

87 8 7
SɅRɅSWɅTI
Department of College of
Computer Engineering Engineering
SɅRɅSWɅTI
// Create a new PhoneStateListener listener = new PhoneStateListener() {

@Override
public void onCallStateChanged(int state, String incomingNumber) {
String stateString = "N/A";
switch (state) {
case
TelephonyManager.CALL_STATE_ID
LE:stateString = "Idle";
break;
case
TelephonyManager.CALL_STATE_OFFH
OOK:stateString = "Off Hook";
break;
case
TelephonyManager.CALL_STATE_RINGI
NG:stateString = "Ringing";
break;
}
textView.append(String.format("\nCallState: %s", stateString));
}
};
// Register the listener wit the telephony manager
telephonyManager.listen(listener,
PhoneStateListener.LISTEN_CALL_STATE);
}
}

Output:

88 8 8
SɅRɅSWɅTI

You might also like