0% found this document useful (0 votes)
470 views

Mobile Computing LAB MANUAL - (2024-25) - 1

Uploaded by

manasishivarkar
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)
470 views

Mobile Computing LAB MANUAL - (2024-25) - 1

Uploaded by

manasishivarkar
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
You are on page 1/ 29

MOBILE COMPUTING (410245(C)) Class : BE(Computer)

ZEAL EDUCATION SOCIETY’s


ZEAL COLLEGE OF ENGINEEIRNG AND RESEARCH,
NARHE, PUNE

DEPARTMENT OF COMPUTER ENGINEERING


SEMESTER-I
[A.Y.: 2024 - 2025]

MOBILE COMPUTING(410245(C))
LABORATORY MANUAL

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 1


MOBILE COMPUTING (410245(C)) Class : BE(Computer)

Institute and Department Vision and Mission

INSTITUTE To impart value added technological education through pursuit of academic excellence,
VISION research and entrepreneurial attitude.

M1: To achieve academic excellence through innovative teaching and learning process.

INSTITUTE M2: To imbibe the research culture for addressing industry and societal needs.
MISSION

M3: To provide conducive environment for building the entrepreneurial skills.

M4: To produce competent and socially responsible professionals with core human values.

DEPARTMENT To emerge as a department of repute in Computer Engineering which produces


VISION competent professionals and entrepreneurs to lead technical and betterment of
mankind.
M1: To strengthen the theoretical and practical aspects of the learning process by
teaching applications and hands on practices using modern tools and FOSS
technologies.

M2: To endeavour innovative interdisciplinary research and entrepreneurship skills


DEPARTMENT to serve the needs of Industry and Society.
MISSION
M3: To enhance industry academia dialog enabling students to inculcate professional
skills.

M4: To incorporate social and ethical awareness among the students to make them
conscientious professionals.

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 2


MOBILE COMPUTING (410245(C)) Class : BE(Computer)

Department
Program Educational Objectives(PEOs)

PEO1: To Impart fundamentals in science, mathematics and engineering to cater the needs of society
and Industries.

PEO2: Encourage graduates to involve in research, higher studies, and/or to become entrepreneurs.

PEO3: To Work effectively as individuals and as team members in a multidisciplinary environment with
high ethical values for the benefit of society.

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 3


MOBILE COMPUTING (410245(C)) Class : BE(Computer)

Savitribai Phule Pune University


Fourth Year of Computer Engineering (2019 Course)
410245(C): Mobile Computing Laboratory
Teaching Scheme: Credit Examination Scheme:
PR: 04 Hours/Week 02 TW: 25 Marks
PR: 50 Marks

Course Objectives:
➢ To introduce the basic concepts and principles in mobile computing. This includes major techniques
involved, and networks & systems issues for the design and implementation of mobile computing
systems and applications.
➢ To demonstrate the protocols of mobile communication.
➢ To know GSM architecture and support services
➢ To Study on location, handoff management and wireless fundamentals.
➢ To summarize VLR and HLR identification algorithms
➢ To learn current technologies being used on field and design and development of various network
protocol using simulation tools.

Course Outcomes:
On completion of the course, student will be able to-

CO1: Develop a strong grounding in the fundamentals of mobile Networks.


CO2: Illustrate Global System for Mobile Communications
CO3: Classify network and transport layer of mobile communication
CO4: Apply knowledge in MAC, Network, and Transport Layer protocols of Wireless Network
CO5: Design & development of various wireless network protocols using simulation tools.

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 4


MOBILE COMPUTING (410245(C)) Class : BE(Computer)

List of Assignments

Sr. TITLE
No. Group A
To implement a basic function of Code Division Multiple Access (CDMA) to test the orthogonally and
01 autocorrelation of a code to be used for CDMA operation. Write an application based on the above
concept.
Implementation of GSM security algorithms (A3/A5/A8)
02
Write an application that draws basic graphical primitives on the screen.
03

04 Develop a native application that uses GPS location information.

05 Design an android Application for Frame Animation.

Group B
Mini-Projects/ Case Study (Any two)
Mini Project
01
02 Mini Project-
03 Mini Project-
04 Mini Project-

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 5


MOBILE COMPUTING (410245(C)) Class : BE(Computer)

GROUP A: ASSIGNMENT NO 1

Problem Statement:
To implement a basic function of Code Division Multiple Access (CDMA) to test the orthogonally and autocorrelation of
a code to be used for CDMA operation. Write an application based on the above concept.

Aim:
To study the basic function of Code Division Multiple Access (CDMA).

Objective:
To develop a program for CDMA.

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.

How does CDMA work?


To see how CDMA works, we have to understand orthogonal sequences (also known as chips). Let N be the number of
stations establishing multiple access over a common channel. Then the properties of orthogonal sequences can be stated as
follows:
1. An orthogonal sequence can be thought of as a 1xN matrix. Eg: [+1 -1 +1 -1] for N = 4.
2. Scalar multiplication and matrix addition rules follow as usual. Eg:3.[+1 -1 +1 -1] = [+3 -3 +3 -3] Eg: [+1 -1 +1 -1]
+ [-1 -1 -1 -1] = [0 -2 0 -2]
3. Inner Product: It is evaluated by multiplying two sequences element by element and then adding all elements of
the resulting list.
• Inner Product of a sequence with itself is equal to N [+1 -1 +1 -1].[+1 -1 +1 -1] = 1 + 1 + 1 + 1 = 4
• Inner Product of two distinct sequences is zero [+1 -1 +1 -1].[+1 +1 +1 +1] = 1-1+1-1 = 0
To generate valid orthogonal sequences, use a Walsh Table as follows:
Rule 1:

Rule 2:

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 6


MOBILE COMPUTING (410245(C)) Class : BE(Computer)

Where = Complement of WN (Replace +1 by -1 and -1 by +1) Example:

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 long for 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.

Example: Assume 4 stations S1, S2, S3, S4. We’ll use 4×4 Walsh Table to assign codes to them.
C1 = [+1 +1 +1 +1]
C2 = [+1 -1 +1 -1]
C3 = [+1 +1 -1 -1]
C4 = [+1 -1 -1 +1]

Let their data bits currently be:


D1 = -1
D2 = -1
D3 = 0 (Silent)
D4 = +1

Resultant channel sequence = C1.D1 + C2.D2 + C3.D3 + C4.D4


= [-1 -1 -1 -1] + [-1 +1 -1 +1] + [0 0 0 0]
+ [+1 -1 -1 +1]
= [-1 -1 -3 +1]

Now suppose station 1 wants to listen to station 2.


Inner Product = [-1 -1 -3 +1] x C2
= -1 + 1 - 3 - 1 = -4

Data bit that was sent = -4/4 = -1.

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 7


MOBILE COMPUTING (410245(C)) Class : BE(Computer)
Advantages of CDMA:
Unlike other channelization schemes like FDMA or TDMA which divide the channel based on frequency or time slots,
CDMA allows all stations to have access to the full bandwidth of the channel for the entire duration.
Conclusion-: Successfully implemented program for Code Division Multiple Access (CDMA).

Date:
Marks obtained:
Sign of course coordinator:
Name of course Coordinator:

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 8


MOBILE COMPUTING (410245(C)) Class : BE(Computer)

GROUP A : ASSIGNMENT NO 2

Problem Statement: -
Implementation of GSM security algorithms (A3/A5/A8)

Aim: -
To learn about GSM security algorithms (A3/A5/A8)

Objective: -
To understand the basic concept of GSM security algorithms (A3/A5/A8).

Theory Concepts: -

Goals of Security features


The security features should be provided two sided i.e. from the Operator Side as well as User Side
Operator Side: From operator’s point of view it should be ensured that operators

➢ Bill the right person


➢ There should be mechanisms to avoid fraud ·
➢ Services should be protected from

Subscriber side: The security measures need to be more promising and precise on subscriber’s side. They should aim at

➢ Maintaining privacy and anonymity of user which means that identification and location of the subscriber should be
concealed
➢ Confidentiality of communication over air should be maintained by providing proper encryption methods
➢ There should be strong access control mechanisms for devices and SIM card
➢ Only authenticated users should be able to access the network

Rules of GSM Security

The Security features should adhere to the following rules:


1. Should not add much load to voice calls or data communication
2. Should not increase the error rate
3. Should not increase the complexity of system
4. Should not demand for more bandwidth
5. Should be useful and cost efficient

Principles of GSM Security

GSM provides security under following mechanisms: & PU


• Access Control to SIM card: This is done by use of Personal Identification Number (PIN) to get access to the SIM
card
• Anonymity: Hiding the identity and location of user. This is done by using a TMSI number
• Authentication: of subscriber so as to ensure only registered and authorized users have access to network
• Encryption of Data and signal to protect them against interception

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 9


MOBILE COMPUTING (410245(C)) Class : BE(Computer)

Access control

SIM Subscriber identity module stores confidential information which can be personal as well as network specific. It
stores the following information:
• International Mobile Subscriber Identity (IMSI) number: A globally unique identifier allocated to each GSM
subscriber. It is permanently stored both in the HLR of the user and in the SIM of the user terminal. Any GSM
subscriber can be uniquely identified by its IMSI number. This International Mobile Subscriber Identity (IMSI)
number is composed of the Mobile Country Code (MCC, three digits), the Mobile Network Code (MNC, two digits)
and the Mobile Subscriber Identification Number (MSIN, ten digits).

• Subscriber Authentication key (Ki): 128-bit shared key used for authentication of the subscriber by the network

• A3 and A8 Security algorithms: Algorithms used for authentication and generation of cipher key.
Therefore, it is necessary to protect the SIM card.

Access Control Mechanisms


• PIN (Personal Identification Number): GSM provides provision of protection of SIM card by using a PIN. The
user needs to know the PIN to unlock the SIM card. The SIM card automatically “Lock Out” after 3 unsuccessful
attempts by feeding wrong PIN.

• PUK (Personal Unlocking Key): A PIN unblocking key should be entered which is provided by the user to unlock
the SIM which is locked after giving the wrong PIN. If the PUK entered incorrectly a number of times, (normally
10) the access to inform is refused permanently and SIM becomes useless.

Anonymity providing Mechanism

To prevent eavesdropping, the identity of the user should be hidden. The identity of user is hidden by use of TSMI
(Temporary Mobile Subscriber Identity) in place of IMSI of the user. When a MS makes initial contact with the GSM
network, an un encrypted subscriber identifier (IMSI) has to be transmitted. The IMSI is sent only once, then a temporary
mobile subscriber identity (TMSI) is assigned (encrypted) and used in the entire range of the MSC. When the MS moves
into the range of another MSC a new TMSI is assigned. The IMSI is not sent over the radio interface so as to prevent the
user from being traced. A TMSI is used instead of IMSI. It is valid in the area of associated MSC i.e. will be valid only till
the user is in the area of MSC for communication. Outside location area, it is used along with LAI (Location Area
Identification). The TMSI identifies the user along with the location area. The TMSI is updated every time user moves to a
new geographical area. It can contain 4 * 8 bits (4 octets). But all 32 bits as one cannot be allocated. TMSI is stored in SIM
and all 1’s in SIM indicates no TMSI. The VLR must be capable of correlating an allocated TMSI with IMSI of MS to
which it is allocated. At the time of paging, to localize the mobile phone the TMSI is broadcasted.

Authentication and Encryption GSM ensures authentication of subscriber before it can use any services of the
network. At the same time privacy of user data and signal should also be maintained by proper encryption mechanisms.
Three security algorithms are documented in GSM specifications for this purpose. They are called A3, A5 and A8. A3 is
authentication algorithm, A8 is ciphering key generating algorithm and A5 is a stream cipher for encryption of user data
transmitted between mobile and base station. The GSM specifications for security were designed by GSM consortium in
secrecy. The consortium used “Security by obscurity” which says algorithm would be difficult to crack if they are not
publicly available.Therefore algorithms were made available only to hardware and software manufactures and GSM
network operators. A3 and A8 are stored on SIM card and at AUC. A5 is stored on device. A3 and A8 are not that strong
therefore the network providers can use their own algorithms or users can use their own algorithms but the encryption
algorithmA5 is implemented on device and should be identical for all providers. A3 and A8 are symmetric algorithms using
the same key embedded on SIM card.

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 10


MOBILE COMPUTING (410245(C)) Class : BE(Computer)

Figure 2: A8 algorithm

Both are one way functions which means output can be found if inputs are known but it is impossible to find inputs if output
is known. A3 and A8 use COMP128 which is a keyed hash function. Both are one way functions which means output can
be found if inputs are known but it is impossible to find inputs if output is known. A3 and A8 use COMP128 which is a
keyed hash function. It takes 128 bit key and 128 bit RAND number as input and produces 128 bit output. The first 32 bits
of 128 bit form SRES i.e. Signed response and next 54 bits forms the cipher key which is used for authentication and
encryption.

Figure 3: COMP 128 algorithm

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 11


MOBILE COMPUTING (410245(C)) Class : BE(Computer)
Authentication mechanism

Authentication is performed using following entities and a technique called “Challenge Response”
• A3 Algorithm for Authentication
• 128-bit key Kistored at SIM card and AUC
• RAND number auto generated by AUC known as Challenge

Following steps are followed for authentication


1. Mobile station sends IMSI to network
2. Network accepts IMSI and find corresponding Ki which is 128 bit secret key stored on the SIM card as well as
available with the authentication center
3. The AUC generates 128 bit random number RAND and sends to the mobile station. This is called “challenge”
4. SIM card accepts this challenge and uses the random number and key Ki as input to A3 algorithm. SIM has a micro-
controller to execute the algorithm A3. It produces 32 bit output called signature response SRES using Ki and
RAND as input
5. Network also calculates output using same inputs i.e. Ki,RAND and algorithm A3.
6. MS sends SRES to network
7. Network matches both SRES, if matched subscriber is authenticated.
The above-mentioned steps are described in the activity diagram and block diagram shown in Fig. 4&5

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 12


MOBILE COMPUTING (410245(C)) Class : BE(Computer)
Encryption
The data and signals are encrypted only between mobile station and base station.

Therefore mechanisms for encryption need to be performed both at base station and mobile station. The algorithms A5
and A8 are used for encryption.Any encryption algorithm needs a cipher key. This cipher key is not statically
available. It is dynamically generated using A8 algorithm. It takes 128-bit key Ki and 128 bit RAND to generate 54 bit
cipher key. Then 10 zero bits are appended to the key to make it 64-bit. This is done to reduce the key space from 64
bits to 54 bits.

A5 algorithm
A5 is the encryption algorithm. It is a stream cipher. It works on bit-by-bit basis. A5 is stored on hardware as it has to
encrypt and decrypt data during transmission and reception of information, which must be fast enough. A5 takes 64-bit
cipher key and 22 bit function key as input and 114 bit plain text to generate 114-bit cipher text (Fig.7). The
encryption decryption processes are performed both at Base station and Mobile station.
A5 is not implemented as block cipher
The reason being that bit error rate on the wireless links is high. If there is an error of single bit in the cipher text it
affects an entire clear text frame. In contrast to it, by using a Stream cipher, a single bit error in the cipher text affects
only one single clear text bit. Therefore stream cipher is used for encryption in GSM. There are many
implementation of algorithm. Most common one being A5/0 A5/1 A5/2 A5/3 A5/1 is the strongest one. A5/0 is
literally no encryption.

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 13


MOBILE COMPUTING (410245(C)) Class : BE(Computer)
Steps followed during encryption
• Network initiates a ciphering mode request command
• Mobile station receives this command
• Network sends RAND number generated to generate the cipher key
• Mobile station uses RAND, Ki and RAND the network also generates Kc and distributes to BS
• As long as user is authenticated Kc remains same. If authentication is done again, another cipher key would be
generated. During handovers if the mobile station has moved to a different base station but there is no need to
authenticate it again, then the same key can be used by the new base station. The key would be forwarded to
the new base station
• Once the cipher key is generated, it can be used to encrypt the data and signal using A5 algorithm.

GSM security issues


• Security is not implemented in fixed part
• Encryption only between base station and mobile Length of Kc (cipher key) is 64 bits which is not sufficient
enough
• Authentication is from mobile station to network and vice versa is not possible
• No measures to maintain Integrity is provided
• Ciphering algorithms are not available for public

Conclusion: To learn about GSM security algorithms (A3/A5/A8).

Date:
Marks obtained:
Sign of course coordinator:
Name of course Coordinator :

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 14


MOBILE COMPUTING (410245(C)) Class : BE(Computer)

GROUP A: ASSIGNMENT NO 3

Problem Statement: -
Write an application that draws basic graphical primitives on the screen.

Aim: -
To develop an application that draws basic graphical primitives on the screen.

Objective-:
To learn about basic graphical primitives on the screen.

Theory Concepts:

Procedure:
➢ Open eclipse or android studio and create new project
➢ Select our project in the project explorer
➢ Go to res folder and select layout Double click the main xml file
➢ Type the code for main.xml or drag and drop various components used in our program
➢ Drag and drop relative layout and change its properties
➢ Drag and drop image view and change its properties according to our programs
➢ Screen layout can be viewed by clicking graphics layout tab
➢ Include necessary files
➢ Override OnCreate() function
➢ Create Image view and initialize its using id of some components used in the xml program
➢ Save the program
➢ Run the program
➢ Output can be viewed in the android emulator
Activity_main.xml:

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


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView" />
</RelativeLayout>

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 15


MOBILE COMPUTING (410245(C)) Class : BE(Computer)

MainActivity.java:

package com.example.exno3;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.widget.ImageView;
public class MainActivity extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Creating a Bitmap
Bitmap bg = Bitmap.createBitmap(720, 1280, Bitmap.Config.ARGB_8888);
//Setting the Bitmap as background for the ImageView
ImageView i = (ImageView) findViewById(R.id.imageView);
i.setBackgroundDrawable(new BitmapDrawable(bg));
//Creating the Canvas Object
Canvas canvas = new Canvas(bg);
//Creating the Paint Object and set its color & TextSize
Paint paint = new Paint();
paint.setColor(Color.BLUE);
paint.setTextSize(50);
//To draw a Rectangle
canvas.drawText("Rectangle", 420, 150, paint);
canvas.drawRect(400, 200, 650, 700, paint);
//To draw a Circle
canvas.drawText("Circle", 120, 150, paint);
canvas.drawCircle(200, 350, 150, paint);
//To draw a Square
canvas.drawText("Square", 120, 800, paint);
canvas.drawRect(50, 850, 350, 1150, paint);

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 16


MOBILE COMPUTING (410245(C)) Class : BE(Computer)
//To draw a Line
canvas.drawText("Line", 480, 800, paint);
canvas.drawLine(520, 850, 520, 1150, paint);
}}

Conclusion-: Thus, a Simple Android Application that draws basic Graphical Primitives on the screen is developed
and executed successfully

Date:
Marks obtained:
Sign of course coordinator:
Name of course Coordinator :

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 17


MOBILE COMPUTING (410245(C)) Class : BE(Computer)

GROUP A: ASSIGNMENT NO 4

Problem Statement: -
Develop a native application that uses GPS location information.

Objectives:
To develop a native application that uses GPS location information
Theory Concepts:
Procedure-
➢ Open eclipse or android studio and select new android project

➢ Give project name and select next

➢ Choose the android version. Choose the lowest android version (Android 2.2) and select next

➢ Enter the package name. package name must be two word seprated by comma and click finish

➢ Go to package explorer in the left hand side select our project.

➢ Go to res folder and select layout. Double click the main.xml file. Add the code below

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


<RelativeLayout

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

android:id="@+id/relativeLayout1"

android:layout width="match_parent"

android:layout_height="match_parent" >

<Button

android:id="@+id/show_Location"

android:layout width="wrap_content"

android:layout height="wrap_content"

android:text="Show_Location"

android:layout_centerVertical="true"

android:layout centerHorizontal="true"/>

</RelativeLayout>

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 18


MOBILE COMPUTING (410245(C)) Class : BE(Computer)

➢ Now select mainactivity.java file and type the following code.In my coding maniactivity name is
GPSlocationActivity.

➢ Go to src folder and Right Click on your package folder and choose new class and give the class nams as GPStrace

➢ Select the GPStrace.java file and paste the following code.

package gps.location;

import android.app.AlertDialog;

import android.app.Service;

import android.content.Context; import android.content.DialogInterface;

import android.content.Intent;

import android.location.Location;

import android.location.LocationListener;

import android.location.LocationManager;

import android.os.Bundle; import android.os.IBinder;

import android.provider.Settings;

public class GPStrace extends Service implements LocationListener{

private final Context context;

boolean isGPSEnabled=false;

boolean canGetLocation-false;

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 19


MOBILE COMPUTING (410245(C)) Class : BE(Computer)

boolean isNetworkEnabled=false;

Location location:

double latitude:

double longtitude;

private static final long

MIN DISTANCE CHANGE FOR UPDATES-10;

private static final long MIN_TIME_BW_UPDATES-1000*60*1;

protected LocationManager locationManager:

public GPStrace (Context context)

this.context=context; getLocation();

public Location getLocation()

try{ locationManager=(LocationManager) context.getSystemService(LOCATION_SERVICE);

isGPSEnabled=locationManager.isProviderEnabled (Location Manager.GPS PROVIDER);

isNetworkEnabled=locationManager.isProviderEnabled (Locat ionManager.NETWORK PROVIDER);

if (!isGPSEnabled && !isNetworkEnabled) (

}else{

this.canGetLocation=true;

if(isNetworkEnabled) { locationManager.requestLocationUpdates ( LocationManager.NETWORK PROVIDER, MIN


TIME BW UPDATES,

MIN DISTANCE CHANGE FOR UPDATES,this);

if(locationManager!=null){

location=locationManager.getLast KnownLocation (LocationMa nager.NETWORK PROVIDER);

if(location!=null)(

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 20


MOBILE COMPUTING (410245(C)) Class : BE(Computer)
latitude=location.getLatitude();

longtitude-location.getLongitude();

if(isGPSEnabled) (

if(location==null){

locationManager.requestLocationUpdates (LocationManager.G

PS_PROVIDER, MIN_TIME_BW_UPDATES, MIN DISTANCE CHANGE FOR UPDATES, this);

if (locationManager!=null){

location=locationManager.getLastKnownLocation (LocationMa nager.GPS_PROVIDER);

if (location!=null) {

latitude-location.getLatitude();

longtitude=location.getLongitude();

catch (Exception e)

e.printStackTrace();

return location;

public void stopUsingGPS () {

if (locationManager!=null) {

locationManager.removeUpdates (GPStrace.this);

public double getLatitude () {

if (location!=null){

latitude=location.getLatitude();

return latitude;

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 21


MOBILE COMPUTING (410245(C)) Class : BE(Computer)
public double getLongtiude(){

if (location!=null) (

longtitude=location.getLatitude();

} return longtitude;

public boolean canGetLocation()(

return this.canGetLocation:

public void showSettingAlert(){

AlertDialog.Builder alertDialog=new AlertDialog.Builder(context);

alertDialog.setTitle("GPS is settings");

alertDialog.setMessage("GPS is not enabled. Do you want to go to setting menu?");

alertDialog.setPositiveButton("settings", new

DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int

which) (

Intent intent-new

Intent (Settings.ACTION LOCATION SOURCE SETTINGS); context.startActivity(intent);

});

alertDialog.setNegativeButton("cancel", new DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int

which) {

// TODO Auto-generated method stub dialog.cancel();

alertDialog.show();

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 22


MOBILE COMPUTING (410245(C)) Class : BE(Computer)
@Override

public void onLocationChanged (Location location) (

// TODO Auto-generated method stub

@Override

public void onProviderDisabled(String provider) ( // TODO Auto-generated method stub

@Override

public void onProviderEnabled(String provider) (

// TODO Auto-generated method stub

@Override

public void onStatusChanged (String provider, int status,

Bundle extras) f

// TODO Auto-generated method stub

@override

public Binder onBind(Intent intent)

// TODO Auto-generated method stub

return null
}
}

➢ Now go to main.xml and right click select run as option and select run configuration

➢ Android output is present in the android emulator as shown in below.

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 23


MOBILE COMPUTING (410245(C)) Class : BE(Computer)

Conclusion: -
uccessfully developed a native application that uses GPS location information.

Date:
Marks obtained:
Sign of course coordinator:
Name of course Coordinator :

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 24


MOBILE COMPUTING (410245(C)) Class : BE(Computer)

GROUP A: ASSIGNMENT NO 5
Problem Statement:
Design an android application for frame animation
Aim:
To understand the android application for frame animation.

Objective:
To design an android application for frame animation.

Theory Concepts:
In Android Frame Animation, you will be swapping frames repeatedly, so that it appears continuous to the human eye and
we feel that it is animated. Frame is referred to an image. So to implement frame by frame animation in android, one needs
to have set of images, which describes a motion.

Step 1- Create a drawable folder


Within it create an animation_list.xml file.
It includes:

A list of items that has the addresses of the frame images.


<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false">
<item android:drawable="@drawable/blank" android:duration="210" />
<item android:drawable="@drawable/logo" android:duration="210" />
<item android:drawable="@drawable/logo1" android:duration="210" />
<item android:drawable="@drawable/logo2" android:duration="210" />
<item android:drawable="@drawable/logo3" android:duration="210" />
<item android:drawable="@drawable/logo4" android:duration="210" />
<item android:drawable="@drawable/logo5" android:duration="210" />
<item android:drawable="@drawable/logo6" android:duration="210" />
<item android:drawable="@drawable/logofinal" android:duration="210" />
</animation-list>

Step 2: Create an activity_main.xml file


It Includes: An Image View
<span style="font-size: 13px; text-align: center;">Here we are done with the xml part, see the image below for reference :-
</span>
<p style="text-align: center;"><a href="<a href="https://www.edureka.co/blog/frame-animation-in-
android/">https://www.edureka.co/blog/frame-animation-in-android/</a>" target="_blank"><img class="aligncenter size-
full wp-image-2382" title="XML part in Frame animation" alt="XML part in Frame animation" src="<a
href="https://d1jnx9ba8s6j9r.cloudfront.net/blog/wp-
content/uploads/2013/02/Project.jpg">https://d1jnx9ba8s6j9r.cloudfront.net/blog/wp-
content/uploads/2013/02/Project.jpg</a>" width="845" height="603" /></a></p>
<strong> </strong>
<h2><span style="font-size: large;"><strong>Step 3- Outside the onCreate method :</strong></span></h2>
<strong></strong>

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 25


MOBILE COMPUTING (410245(C)) Class : BE(Computer)
Declare the Image View and Animation Drawable

[code lang="java"]
// Declaring an Image View and an Animation Drawable
ImageView view;
AnimationDrawable frameAnimation;

Step 3- Inside the OnCreate method:


• Typecast the Image view
• Typecast the Animation Drawable
• Set the drawable background on the image view

// Typecasting the Image View


view = (ImageView) findViewById(R.id.imageAnimation);

// Setting animation_list.xml as the background of the image view


view.setBackgroundResource(R.drawable.animation_list);

// Typecasting the Animation Drawable


frameAnimation = (AnimationDrawable) view.getBackground();

Step 4- After the onCreate method :


The animation should only run when it is in focus that is when it is visible to the user. Hence define this method after the
onCreate method.

// Called when Activity becomes visible or invisible to the user


@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
// Starting the animation when in Focus
frameAnimation.start();
} else {
// Stoping the animation when not in Focus
frameAnimation.stop();
}
}

So the final result will look like this:

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 26


MOBILE COMPUTING (410245(C)) Class : BE(Computer)

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 27


MOBILE COMPUTING (410245(C)) Class : BE(Computer)

Conclusion: -
Successfully implemented an android application for frame animation

Date:

Marks obtained:

Sign of course coordinator:


Name of course Coordinator :

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 28


MOBILE COMPUTING (410245(C)) Class : BE(Computer)

Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 29

You might also like