design and implementation of a situation aware android application for...

74
i Design and Implementation of a Situation Aware Android Application for the Safety of the Memory Impaired GRADUATE PROJECT Submitted to the Faculty of the Department of Computing Sciences Texas A&M University-Corpus Christi Corpus Christi, Texas In Partial Fulfillment of the Requirements for the Degree of Master of Science in Computer Science By Aneeli Bhartepudi Spring 2017 Committee Members Dr. Ahmed Mahdy __________________________ Committee Chairperson Dr. David R. Thomas _______________________ Committee Member

Upload: others

Post on 09-Apr-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

i

Design and Implementation of a Situation Aware

Android Application for the Safety of the Memory

Impaired

GRADUATE PROJECT

Submitted to the Faculty of

the Department of Computing Sciences

Texas A&M University-Corpus Christi

Corpus Christi, Texas

In Partial Fulfillment of the Requirements for the Degree of

Master of Science in Computer Science

By

Aneeli Bhartepudi

Spring 2017

Committee Members

Dr. Ahmed Mahdy __________________________

Committee Chairperson

Dr. David R. Thomas _______________________

Committee Member

Page 2: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

ii

ABSTRACT

Modern smart phones are well equipped with different sensors along with specialized and

innovative hardware that can open the door for a plethora of capabilities. With these

additional capabilities offered by smart phones, it has become much easier for every user

to act as a data gathering agent. These features provided by the smartphones can be very

advantageous in enhancing the living conditions of people. By making use of the context

and location awareness of such smart phones, this project aims to develop a situation aware

android application that can be used to help with the safety of individuals that may be in

need for such support; for example, elderly and the memory impaired. The application will

keep track of the location of the user. Based on pre-identified conditions like geo-fencing,

time of the day…etc., the application will accordingly notify a set group of individuals

with necessary information including the current location. In, additional to these features

the application is also intended to assist a person in case of an emergency by capturing the

movements of the phone with the help of an accelerometer, which will trigger a specific

alert message to selected contacts.

Page 3: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

iii

TABLE OF CONTENTS

ABSTRACT ........................................................................................................................ ii

TABLE OF CONTENTS ................................................................................................... iii

LIST OF FIGURES ............................................................................................................ v

LIST OF TABLES ............................................................................................................. vi

1. BACKGROUND AND RATIONALE ........................................................................... 1

1.1 Related Work ...................................................................................................... 2

1.2 Android ............................................................................................................... 3

1.3 Geo-Fencing ........................................................................................................ 3

2. NARRATIVE ................................................................................................................. 4

2.1 Problem Statement .............................................................................................. 4

2.2 Motivation ........................................................................................................... 4

2.3 Product Description ............................................................................................ 5

2.4 Product Scope ..................................................................................................... 5

2.5 System Requirements .......................................................................................... 6

3. DESIGN OF THE APPLICATION ................................................................................ 7

3.1 Module Description ............................................................................................ 7

3.1.1 Database ................................................................................................. 7

3.1.2 Location .................................................................................................. 8

3.1.3 Google Maps ........................................................................................... 8

Page 4: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

iv

3.1.4 Area Creation .......................................................................................... 9

3.1.5 Contacts .................................................................................................. 9

3.1.6 Gestures ................................................................................................... 9

3.1.7 Location Listener .................................................................................... 9

3.1.8 Battery Thread ...................................................................................... 10

3.1.9 Notifications .......................................................................................... 10

4.DEVELOPED SYSTEM DESIGN ................................................................................ 11

4.1 System Overview ........................................................................................... 14

4.2 Use Case Diagram ........................................................................................... 17

4.3 Sequence Diagram ......................................................................................... 19

4.2 Class Diagram ................................................................................................ 21

4.3 User Interface ................................................................................................. 22

5. IMPLEMENTATION OF THE APPLICATION MODULES

5.1 Screen_One ................................................................................................... 33

5.2 Setting permission in AndroidManifest.xml ................................................. 33

5.3 Emergency_contacts ..................................................................................... 34

5.4 Login ............................................................................................................. 35

5.5 Main Activity ................................................................................................ 36

5.6 Registration ................................................................................................... 39

5.7 User_locations ................................................................................................ 40

Page 5: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

v

5.8 Resources ..................................................................................................... 40

6. TESTING AND EVALUATION ................................................................................. 42

6.1 Launching the application ........................................................................... 42

6.2 Login ........................................................................................................... 43

6.3 Current Location ......................................................................................... 45

6.4 Views .......................................................................................................... 46

6.5 Clear Map.................................................................................................... 47

6.6 Contacts....................................................................................................... 47

6.7 Emergency contact list ................................................................................ 49

6.8 User location .............................................................................................. 50

6.9 Creating fences ............................................................................................ 50

6.10 Message..................................................................................................... 51

6.11 Gestures..................................................................................................... 52

6.12 Results ....................................................................................................... 53

7.CONCLUSION AND FUTURE WORK ...................................................................... 57

BIBLIOGRAPHY and REFERENCES ............................................................................ 59

APPENDIX ....................................................................................................................... 63

Page 6: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

vi

LIST OF FIGURES

Figure 2.2.1. Three families of smartphones based positioning solutions .......................... 5

Figure 3.2. Architecture of the application ....................................................................... 11

Figure 3.3 Gesture movements across x and y axes ......................................................... 12

Figure 4.1.1 Architecture of the admin module ................................................................ 14

Figure 4.1.2 Architecture of the user module ................................................................... 16

Figure 4.3.1: Sequence diagram for admin ....................................................................... 18

Figure 4.3.2 Sequence diagram for user .......................................................................... 19

Figure 4.4 Class diagram of the application ..................................................................... 20

Figure 4.5.1 App logo and the main screen ..................................................................... 21

Figure 4.5.2 Login screen ................................................................................................. 22

Figure 4.5.3 About page.................................................................................................... 23

Figure 4.5.4 User registration ........................................................................................... 24

Figure 4.5.5.1 Map activity for admin .............................................................................. 24

Figure 4.5.5.2 Satellite and street view of the map ........................................................... 25

Figure 4.5.5.3 Settings dropdown menu ........................................................................... 26

Figure 4.5.5.4 Current location ......................................................................................... 26

Figure 4.5.5.5 User location listview ................................................................................ 27

Figure 4.5.5.6 Message dialog box ................................................................................... 28

Figure 4.5.5.7 Contact list ................................................................................................. 29

Page 7: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

vii

Figure 4.5.5.8 Creating a geo-fence .................................................................................. 30

Figure 4.5.5.9 user mapActivity ....................................................................................... 31

Figure 5.1 Screen_one ...................................................................................................... 32

Figure 5.2 Permission in Android manifest file ................................................................ 33

Figure 5.3.1 Emergency contact list and deleting a contact from the list ......................... 34

Figure 5.3.2 Retrieving contact list ................................................................................... 34

Figure 5.4 Login modules ................................................................................................. 35

Figure 5.5.1 User login page ............................................................................................. 36

Figure 5.5.2 Satellite and street view ................................................................................ 36

Figure 5.5.3 Creating geo-fence ........................................................................................ 37

Figure 5.5.4 Alert dialog box ............................................................................................ 37

Figure 5.6.1 New user registration .................................................................................... 38

Figure 5.6.2 Check for duplication ................................................................................... 39

Figure 5.7 User location retrieval ..................................................................................... 39

Figure 5.8.1 Drawable folder resources ............................................................................ 40

Figure 5.8.2 Colors.xml .................................................................................................... 40

Figure 5.8.3 Strings.xml.................................................................................................... 41

Figure 6.1 launching the application ................................................................................. 43

Figure 6.2 login page of the application .......................................................................... 43

Figure 6.2.1 Registration values validation ...................................................................... 44

Page 8: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

viii

Figure 6.2.2 Check for data duplication ............................................................................ 44

Figure 6.2.3 validating credentials .................................................................................... 45

Figure 6.3 Current location of admin ................................................................................ 45

Figure 6.4 street and satellite view ................................................................................... 46

Figure 6.5 clear map activity check .................................................................................. 46

Figure 6.6.1 viewing contacts in the phone ...................................................................... 47

Figure 6.6.2 Add to emergency contact list ...................................................................... 47

Figure 6.6.3 Adding contact to the list .............................................................................. 48

Figure 6.7.1 removing contact from the emergency contact list ....................................... 48

Figure 6.7.2 Empty contact list check ............................................................................... 49

Figure 6.8 viewing user locations and clearing the list ..................................................... 49

Figure 6.9.1 Creating a danger zone ................................................................................. 50

Figure 6.9.2 Error checking for geo-fence creation .......................................................... 51

Figure 6.10 Enter message for alert .................................................................................. 51

Figure 6.11 Gesture activity .............................................................................................. 52

Figure 6.12.1 Creating a danger geo-fence ....................................................................... 53

Figure 6.12.2 Message received by the contact added to the list ...................................... 54

Figure 6.12.3 Entering a danger zone geo-fence .............................................................. 54

Figure 6.12.4 Gesture message received by the contact added to the list ......................... 55

Figure 6.12.5 Battery level displayed as toast alert and Battery alert message ....... 55

Page 9: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

ix

LIST OF TABLES

Table 6.12: Feedback for the application……………………………………………58

Page 10: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

1

1. BACKGROUND AND RATIONALE

Situation Awareness is the capability of mobile devices that works complimentarily with

location awareness and context awareness. The location service determines how certain processes

operate around a device, whereas context can be applied more flexibly with users of smartphones.

By utilizing this context awareness property integrated with the location based features, the idea

is to develop an application that will be proven useful in learning about the whereabouts of a person

[1]. The location services assist in locating the user and updating the new location details to the

selected contact list.

The functioning of the application comprises a concept called Geo-Fencing, in which an

area is marked on a map and a virtual fence is created around the chosen point. The application is

developed by keeping in mind the requirements of the different classes of people, who need to be

monitored constantly, for example, children, senior citizens and the memory-impaired. Any person

wanting to know the whereabouts of their family members or friends can make use of this

application. The current location of the device held by the user is detected and a notification or an

alert text is sent to the chosen contacts. The expediency of this application is that it aids individuals

in their everyday lives, thus the needs of children and senior citizens are primarily taken into

consideration [2].

Human behavior modeling and activity interpretation are of increasing interest in the

information society. Social applications such as assisted living and abnormal activity detection

draw a lot of attention among scientists. [3] Meanwhile, smartphone sensing technologies are

nowadays developing at an incredible pace. The smartphone boasts a healthy variety of sensor

options for sensing the social environment [4]. Various locating and context related sensors and

Page 11: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

2

network technology are embedded into mobile phones, features such as GPS, WLAN (a.k.a.

Wi-Fi), cellular network antennae, Bluetooth, accelerometers, magnetometers, gyroscopes,

barometers, proximity sensors, humidity sensors, temperature sensors, ambient light sensors,

cameras, microphones, etc. With this array of input or stimulus options, coupled with capable

computational and networking functions, the smartphone becomes an attractive “cognitive”

platform.

1.1 Related Work

To develop an application that will be useful in a real-life scenario, it is essential to study

and review the requirements of different classes of people and also learn about if there are any

existing applications that provide similar functionalities.

1.1.1 Sygic Family

Sygic Family is an application that notifies about the user location. It lets parents check the

whereabouts of the children and confirm whether they have reached their destination. The

application enables the user to send messages through the internet. The application also

makes use of Google Maps and sends the current location of the user. [5]

1.1.2 Mama Bear

Mama Bear application is capable of sharing locations between users. Furthermore, it

allows parents to monitor any received messages from their child’s phone and check any

sign of online bullying or inappropriate language by setting a security password locking

mechanism on the messages received on the device. [6]

Page 12: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

3

1.1.3 Find My IPhone

Find My IPhone is an application provided in the IOS devices that makes use of the GPS

within the mobile device to track the iPhone in case of a lost or stolen device. [7]

These applications send the current location of the user’s device. The application developed will

retrieve the user’s current location and in addition to that it will also be able to trigger specific

events by detecting the gestures of the user by sensing the movements of the handheld device.

These gestures are set to perform a specific action associated with it.

1.2 Android

Different mobile operating systems have been developed, but Android is one of the mostly

used mobile operating systems in today’s world. It is a free and open source operating system

which is developed and maintained by Google. Because of it being an open source, it is highly

available for the developers to create new applications. In contrast with iOS which is specific only

to the IPhone users and is not an open-source platform. Many versions of android have been

released to date, each having several updates. Each new version is named after a dessert, going in

alphabetical order like: cupcake (Version 1.5) followed by Donut (Version 1.6), Éclair (Version

2.0 – 2.1), Froyo (Version 2.2), Gingerbread (Version 2.3), Honeycomb (Version 3.0 – 3.2), Ice

Cream Sandwich (Version 4.0), Jelly Bean (Version 4.1- 4.3), KitKat (Version 4.4), Lollipop

(Version 5.0 – 5.1), Marshmallow (6.0-6.0.1) and latest version Nougat (7.0 – 7.1.1). The system

as such comes with many built-in API’s and because of it being open source, various applications

are being developed depending on the needs and are being put on the Play Store for everyone to

use [8].

Page 13: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

4

1.3 Geo-Fencing

A Geo-fence can be defined as a virtual barrier. Geo-fencing is creating virtual boundaries

around a point using Global Positioning System(GPS) [9]. When a device enters these boundaries,

it will trigger a reminder about the current location. One example of usage involves a location-

aware device of a location-based service (LBS) user entering or exiting a geo-fence. This activity

could trigger an alert to the device's user as well as messaging to the geo-fence operator.

Page 14: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

5

2.NARRAVTIVE

2.1 Problem Statement

The use of smartphones has simplified the way of living. With the growth in technology,

new ways to assist people with special needs has become simpler. The safety of our family &

friends is our top most priority, for this purpose knowing the location of the person is needed in

case of an emergency [3]. Although there are few existing applications that will provide the

information about the current location of the person when the user explicitly requests for the

location details. Since the user who wants to know the whereabouts of the person may not be able

to request for the information at all time, it would be much easier if the retrieving of the information

can be automatic in the form of a message/alert rather than the user requesting for the location

details at all times

2.2 Motivation

To know the whereabouts of family/friends, especially the ones who might need assistance

is a top priority. For instance, a person suffering from memory impairment might not be able to

get back home or any place he/she is supposed to be in. It would be helpful if the location of such

individuals could be sent to the person listed as an emergency contact, who will then be able to

assist the member in need. The location details are sent to the emergency contacts by determining

if the person is within the danger zone that is defined using Geo-Fencing. The applications such

as “Find My IPhone” that exists for IOS [7], can locate the current location of the device when a

search for the device is performed, this lack sending any alerts in case of an emergency. For this

purpose, an application that will be able to send a customized alert message while utilizing the

context awareness as well as show the current location of the user using the location awareness.

Page 15: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

6

The movements of the handheld device can be captured by the co-ordinates of the device with the

help of the accelerometer, triggering messages when the co-ordinate values of the defined

movements match. Figure 2.2.1 describes the different features that the smartphones offer.

Figure 2.2.1. Three families of smartphone-based positioning solutions

2.3 Product Description

The Application is being developed for assisting the memory-impaired, senior citizens and

children by notifying the emergency contacts in the application about their current location by

integrating the Google Maps and Geo-Fencing concepts. The context Awareness of the hand-held

device will help in identifying the movement of the phone, in turn trigger a specific event

associated with it. This reminder application is compatible from Android 5.0 to the latest version.

2.4 Product Scope

As previously mentioned, the application has a varied scope as it can be used by different

age groups for example, senior citizens and children. Also, the application is being developed by

keeping in mind the special needs for certain demographics of people like memory impaired,

Alzheimer’s, etc.

Page 16: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

7

2.5 System Requirements

The application is being developed for the Android platform and has the following

requirements:

Operating System: Windows/MAC

Windows and MAC both provide user-friendly environments for development of the

code with suitable Android IDE (Integrated Development Environment).

Database: SQLite

The application requires the data to be stored in the format of tables which is a key

functionality provided by the SQLite database.

IDE: Android Studio

Android studio is the standard IDE provided by Android, which I have used for

developing the application

Software: Android SDK (Software Development Kit), Java SE 7

The coding for android is done using JAVA, the code for the application has been built in

JAVA SE 7.

Android Device: Android phone (version 5.0 and above)

The application being developed is compatible with Android version 5.0 and above. The

application functions well on different android phone models that are version 5.0 or above.

Page 17: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

8

3. DESIGN OF THE APPLICATION

The implementation of the application can be categorized into 9 modules based on the features

that the application provides. Each module has been categorized by considering the usage within

the application along with its characteristics.

3.1 Module Description:

The following are the modules that are implemented within the application. Each module has

its own functionalities and features. These various features integrated together will assist in

development of the application.

3.1.1 Database

The database in this application has been implemented using SQLite. The database

will contain the following:

3.1.1.1 Recent Location Table:

Recent Locations (RL) are the locations that are detected by the GPS of the device.

A new RL is created, but not all RLs are stored in the database. The recent locations

that are stored are the ones that are noticed to be outside of a usual location i.e. if the

device is not within the boundaries of a usual location, any detected recent location

will be stored in the database.

3.1.1.2 Usual Locations table:

As aforementioned, usual locations (UL) are the ones that the device is expected to

be in. They are areas in which the user is usually found in (e.g. their house, grocery

shop, etc.) and are not presumed to be someplace else. A UL can be created manually

Page 18: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

9

by the user simply by placing a marker on the provided digital map and providing a

name for the particular usual location. The user has the option to create three zones

of usual location safe-green, red-danger and yellow-neutral. The user’s location is

monitored when the user is travelling and triggers an alert upon encountering an

entry/exit action with the danger geo-fence.

3.1.1.3 Contacts table:

In a situation when a user steps inside/outside of a danger geo-fence, an SMS will

be sent to a number of designated individuals. When a device, on which the

application is installed, is not within the boundaries of any of the ULs, all the entries

stored in the Contacts table will be retrieved, and an SMS message will be sent to

the list of chosen contacts. In order to add a new entry in the table, the contacts stored

in the device’s phonebook are retrieved and displayed, and the user is given the

option to select any number of them. [9]

3.1.1.4 Gestures table:

The Gestures table is where the information for enabling the context awareness

aspect of the application is stored. The user will be able to perform certain actions

simply by waving the device in a specific manner, and all the data required to make

this happen is stored in this table. More precisely, users will be able to send a

customized message to a phone number of their choosing when activating a certain

gesture. The idea behind implementing gestures is to send an alert when the user

holding the device is not in a position of sending an alert himself. The gestures will

require the co-ordinates value to be precise to trigger the action of an alert. Since the

Page 19: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

10

device being handheld by the user, it is possible that the gesture could trigger an

alert when it is not intended, for this purpose a proposed threshold value must be set

that minimize the false alarms.

3.1.2 Locations

The functioning of the application revolves mainly around the locations. There are two

locations that will be key in determining the action of sending an alert message.

A. Recent location(RL): Recent Location is the temporary location of the user. It gives the

current whereabouts of the device. The recent location is identified using the GPS within

the device, which requires a stable WIFI connection or Mobile Data to detect the current

location.

B. Usual Location(UL): Usual Location is the area in which the device is expected to be

located in.

The recent locations are detected while the phone’s GPS is enabled. Usual locations can be

created and stored at any time required by the user.

3.1.3 Google Maps

To efficiently retrieve the recent location and to determine their preferred usual locations,

Google Maps Activity provided by Android Studio is implemented. The smart Phone version of

Google Maps is shown to the user wherein the user can navigate to any place of his/her choice.

Each time the Map Activity is loaded, the entire list of the stored usual locations are retrieved to

place markers where the previous UL’s were created. Additionally, the map will zoom to the

recently added usual location automatically. [11]

Page 20: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

11

3.1.4 Area Creation

To create a new UL, the user will have to place a marker on the map and define it with a

name. The user can create three geo-fences which can be categorized into green – the safe zone,

yellow-neutral zone and the red-zone which the danger zone and this danger zone is key in

determining the user location, as the user enters or exits this danger zone the messages are

triggered.

Figure 3.2: Architecture of the Application

3.1.5 Contacts

The emergency list of contacts who will be receiving the SMS notification in case of an

event. The event can be either the user enter/exits from the danger geo-fence or the Battery Level

falls under the specified threshold which is when the battery level reaches 15%. This list can be

set up by choosing contacts from the device phone book. The contacts from the list updated as per

the user requirements.

Page 21: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

12

3.1.6 Gestures

To develop an application that enables recognition of specific hand movements(gestures),

the accelerometer embedded in a smartphone is utilized. The accelerometer gathers information

about the movement of the hand-held device by capturing the X, Y co-ordinates depending on

which axis the phone is moved. There are pre-defined gestures that are created within the

application and inserted into the database with specific co-ordinate values set to each gesture. The

acceleration of the device is used as a gesture. [12] The regions in the 3-Dimensional acceleration

are set as different messages, these messages are uploaded to the database with the current battery

status.

Gesture 1: The phone should be moved along the X-axis to trigger this gesture.

Gesture 2; the phone should be moved along the Y-axis to trigger this gesture.

The phone movements across the x and y axis can be seen in figure 3.3.

Gesture1: X-axis Gesture 2: Y-axis

Figure 3.3: Gesture movements across X and Y axes

3.1.7 Location Listener

Location Listener receives information from a Location Manager about any updates done

to the co-ordinates of the device. When a user specifies the desired usual locations, the location

information is gathered and for every set of co-ordinates retrieved, the applications checks whether

the device is inside the defined geo-fence or not. In this module, the user finds the distance between

Page 22: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

13

the UL and the RL the location detected outside the marked usual location, is saved into the

database along with the values of battery level, the distance between the 2 locations and the current

location.

3.1.8 Battery Thread

This thread is responsible for constantly comparing the battery level of the device with the

battery limit that is pre-defined in the Service table of the database. The default value for the

application has set to be 15% (which can be customized if required). If the device battery reaches

15%, an SMS is sent to the contacts stored in the database under the contacts table notifying them

that the battery on the device is running low. The “battery is running low” message has be set into

the code which will be sent when the battery level reaches 15%, the message can be customized

as per user requirements.

3.1.9 Notifications

The application checks for a latest recent location with the list of all stored usual locations,

an SMS message is sent if the particular RL is within the danger geo-fence. The message alert will

be sent to all the entries in the contacts table.

Page 23: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

14

4. DEVELOPED SYSTEM DESIGN

The designed application has been named as “Family Finder” and has the following components:

4.1 System Overview:

The application developed can be categorized into 2 modules- ADMIN and USER.

4.1.1 ADMIN

The admin is the one who has the capability to create the geo-fences and alter/modify

them. The contacts who are to be in the emergency contact list is added by the admin. The admin

is given the rights to modify the emergency contact list. The admin credentials are pre-defined into

the code and are set as Username: “admin”. Password: “1234”. The idea behind creating an admin

and designating him with the rights to create and alter geo-fences is that if only the admin will be

creating the geo-fence, it would be simpler and would not lead to any state of confusion that arises

when multiple users are logging in and creating their own geo-fences. The admin can create a geo-

fence and alter it as per his choice. The architecture design of the admin side can be viewed as

follows:

Figure 4.1.1: Architecture of the admin module

Page 24: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

15

The architecture of the admin module is as follows:

The admin can view the current location of the user in a form of ListView.

The message that has to be sent is set by the admin. The admin will be able to edit/modify

the message content.

Contacts within the phone can be accessed and added to the emergency contact list.

The main feature of the admin module is creating the geo-fences, Safe, Neutral and Danger.

The Safe zone is depicted by green, the yellow circle depicts the Neutral zone, and the Red

Zone is the Danger zone which is solely responsible for triggering the alerts.

The admin is the one who is responsible for sending the alert messages to the people listed

in the emergency contact list.

4.1.2 USER:

The second module of the application is the USER module, wherein the application is installed

on the user’s smartphone device for the services to run in the background.

The user account can be created when a new user registers with his details: name, password, phone

number, email and address. These details are stored into the database that will be useful when a

user wants to login to the application.

Upon logging in, the user will see a map and his current location can be viewed.

The user architecture has the following features:

The user will create an account by registration if he/she is a first-time user.

User will have the gesture services, location services and the battery thread running in the

background.

Contacts added to the emergency contact list will receive an SMS alert when the user

moves in and out of the red Zone.

Page 25: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

16

Figure 4.1.2 Describes the architecture of the user module with the different actions that

the user is capable of doing.

Figure 4.1.2: Architecture of the user module

4.2 Use Case Diagram:

The use case diagram of the application is shown in Figure 4.2. The purpose of the use case

is to represent the graphical overview of the functionalities provided by the system. The oval

shapes represent the functionalities the admin and user hold. Each functionality can be identified

by the associated name within the oval shape.

Page 26: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

17

Figure 4.2: Use-Case diagram of the application

The Admin and User are 2 modules that will be used to login to the application. The admin

has the right to create geo-fences that will be used to monitor the location of the user. The admin

sets an alert message that will be received by the list of contacts that will be added by the admin

to the emergency contact list. The current location of the user is retrieved and can be viewed in the

form of a list displaying the latitude and longitude values in a form of ListView along with the

username.

The admin will be able to create 3 geo-fences: Green, which is the safe zone, Yellow, which

is the neutral zone, and the Red zone that depicts the danger zone. The red zone is the most critical

as the alert messages are triggered when the user enters/exits this zone. The user will have the

option to enable or disable the gestures by clicking on a checkbox; the message that has to be sent

when a gesture occurs is set by the user. The current location of the user is retrieved and is stored

in the database that can be viewed by the admin.

Page 27: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

18

4.3 Sequence Diagram:

A sequence diagram describes how the communication will happen between the user, the

application, and the local database.

4.3.1 Admin Module:

Figure 4.3.1 describes the admin sequence with the application and the features that the

application holds that the user of the device can make use of when he logs in as an admin. The

user when logging in as an admin will create geo-fences, add contacts to the emergency list, set

the message to be sent, and view the location of the user. The contacts are added into the SQLite

database along with the current location that will be retrieved from the user module which can be

viewed by the admin. The message entered by the admin will be stored into the SQLite database

to be sent to the user when needed, i.e. when the user moves in/out of the danger zone or if the

sensor manager detects the occurrence of a gesture.

Figure 4.3.1: Sequence diagram for admin

Page 28: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

19

4.3.2 User Module:

The user interaction with the application can be seen in Figure 4.3.2, the user creates an

account after which he will be able to log into the application. The movement of the user is

monitored by utilizing the GPS built within the smartphone. the location services run in the

background even when the application is closed to know the current location. This location is sent

to the Location table within the SQLite database when the location is detected outside the

red(danger) zone. The user module has the feature of enabling the gestures: Horizontal movement

and the diagonal movement are the 2 gestures defined within the application. The sensor detector

built within the phone are run in the background as a service to detect when a gesture occurs and

triggers an alert message when one such gesture is identified. The user will have to set the message

that will be sent when a gesture is identified.

Figure 4.3.2: Sequence diagram for user

Page 29: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

20

4.4 Class Diagram:

Class diagram is a type of static diagram that represents classes in the system. the diagram

depicts the different interfaces, methods, variables and the relationship between them. Figure 4.4

shows the class diagram for the Family Finder application for the user and admin modules and the

functionalities each module holds. For each class, the diagram shows the information about its

methods.

Figure 4.4: Class diagram of the application

Page 30: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

21

4.5 User Interface:

This section gives an overview of the user interface of the Family Finder application. The

outlook of the application displaying all the features of the application can be seen as below:

4.5.1 Main Screen:

This Activity is the first screen that appears when the application is opened. It displays the

application title and the logo. This screen displays 2 buttons: Login and about. Each of these

buttons is again associated with another layout linked to its specific activity and class. A click on

the login button will open the login page, and the about button will lead to the about page.

Figure 4.5.1: App logo and the main screen

Page 31: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

22

4.5.2 Login Page:

The login page has option to enter the username, password and login as “ADMIN”,”USER”

and also allows new users to register as “New User”.

The admin credentials are predefined as username- “admin”, password- “1234”. After entering

these credentials and hit ADMIN to log in as administrator.

The new user register here button will redirect to another page to create a new user account.

Figure 4.5.2: Login screen

4.5.3 About Page:

This page gives information about the application. It describes what the application provides to

the user. The idea of this page is to give a brief introduction to the application.

Page 32: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

23

Figure 4.5.3: About page

4.5.4 Registration Page:

This page provides the user a registration form to create a user account. The user will have

to enter a username, password, email address and address. The entries are checked against

duplicate data and the correct format of data.

After successful creation of account, the user will be presented a dialogue box to navigate

back to the previous screen.

Page 33: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

24

Figure 4.5.4: User registration

4.5.5 Map Activity: The layout that are viewed by the admin and user are as follows:

4.5.5.1 Admin Login:

The admin side Main Activity of the application is where all the main features of the

application appear.

Figure 4.5.5.1: MapActivity page for admin

Page 34: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

25

4.5.5.2 Views:

The layout displays two buttons, Satellite view and Street View. clicking on each of them

will display the respective views of the map. The purpose of giving user the option of two views

is to increase the accuracy of understanding the maps which the user will be able to create

appropriate geo fences. The views can be toggled from one view to another.

Figure 4.5.5.2: Satellite view and street view of the map

4.5.5.3 Settings:

Settings drop-down menu provides various options to the admin by which the application

can be set to specific functionality as per user requirements. The setting drop down is available

only to the admin module as all the modifications can be performed only to the admin.

Page 35: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

26

The settings dropdown can be clicked on to view the various options it provides to the admin of

the application. The settings tab holds 4 main key features on which the admin will have privileges

to change/modify.

Figure 4.5.5.3 Setting dropdown menu

The dropdown menu can be expanded to view the following features:

Current location: The user’s current location is displayed on the screen with a pointer. This

facilitates the user to create a geo-fence around his current location.

Figure 4.5.5.4 Current location

Page 36: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

27

User location: when this button is clicked, a ListView is opened, which displays the

latitude and longitude values of the user along with the user name.

Figure 4.5.5.5: Current location and user location ListView

Message: The message tab upon selection displays a pop up window in which the admin

can enter the message he/she wants to send. This tab can be visited again to modify the

message that will be sent as an alert.

The dialog window provides a text field along with CLOSE and YES buttons. The close

will cancel any modifications done to the text, whereas the click on Yes will save the

changes to the text message.

Page 37: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

28

Figure 4.5.5.6: Message dialog box

Contacts:

This option allows the user to add the contacts to the emergency contact list. When

this option is selected from the settings dropdown, the contacts that are saved in the device

are viewed and can be selected to be added onto the emergency contact list. The “view

emergency contact list” option upon selection opens up a listView to view the contacts

added into the list. Each contact can be clicked on to view an option to delete it form the

list.

Page 38: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

29

Figure 4.5.5.7: Contacts list

4.5.5.4 Clear Map:

The clear map button erases all the existing geo-fences. The purpose of this feature is to

provide the ability of clearing the map to the user in order to create new geo-fences.

4.5.5.5 Geo-Fencing:

The bottom button on the main screen layout is used to create geo-fences, the button

initially displays “tap on map to place marker”, upon clicking on this button a marker will be

placed on the screen where the admin desires, the button now displays “click here to create

fencing”, upon clicking this, a window will be displayed that will ask about the requirements for

creating a geo-fence, the radius that will be set for the geofence, the radius may vary from 100-

999 meters. The geo-fence created will be given a name eg. School, office etc. The next thing is

choosing which category the geo-fence will belong to. The user is given 3 options to choose from,

green(safe), red(danger) and yellow(Neutral). The “start fencing” button can be clicked when the

Page 39: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

30

desired parameters are set and the geo-fence will be created in a circular shape and the size of the

circle depends on the radius mentioned by the user and can viewed on the map.

Figure 4.5.5.8: Creating a geo-fence

4.5.5.6 User login:

After successfully creating an account, the user is able to login with the credentials he/she

created. After logging in the user will view a map that will be showing his current location. The

user MapActivity has an additional feature of providing the user option of selecting the checkbox

when he/she wants the gestures to be enabled. The checkbox can be deselected when the user no

longer wishes the gestures to be detected and trigger an alert message. Along with this the user

will be able to set the message that will sent to the contacts added to the emergency contact list

when a trigger has been identified.

Page 40: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

31

Along with this the user activity page also displays the option to move from street view to

satellite view and vice-versa.

Figure 4.5.5.9: User MapActivity

The gestures that have been implemented within the application are handled by the

sensorManager which integrates with the hardware sensors within the application. There is no pre-

defined function to implement the gestures, each gesture is et using a threshold value range for

each axis. The x-axis must be specified a range from x to -x and similarly y axis which lies in

between y to -y. if the application detects any values that lie between the specified ranges, the

gesture alert message is triggered.

Page 41: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

32

5. IMPLEMENTATION OF THE APPLICATION MODULES

The following sections describes the different classes used in the application showing the

important code segments of the application.

5.1 Screen_One:

This is the first class that runs when the application is opened. In this class, the creation of

the SQLite database object “dbase” is done.

When the application is run for the first time, a new database is created and creates three tables for

contacts, users and locations. the application upon re-open uses the same database created during

first time use.

Figure 5.1: Screen one

5.2 Setting permissions in AndroidManifest.xml:

AndroidManifest is an auto-generated file by the android studio and is mandatory for every

application. This file includes all the smartphone features that the application is requesting

permissions to access. The file holds all the essential information about the application. Figure 5.2

Page 42: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

33

displays the list of permissions the Family Finder application is required to make use of the GPS

and the hardware sensors within the phone.

ACCESS_FINE LOCATIONS- It allows the application to get information about the

latitude and longitude values.

READ_CONTACTS – It allows the phone to get access to the contacts stored within the

device.

SEND_SMS, READ_SMS, RECEIVE_SMS – these permissions allow the application to

send the alerts in the form of text messages.

Figure 5.2: Permission in Android manifest file

5.3 Emergency_contacts:

This class is responsible for adding the contacts accessed from the phone to a table in the

SQLite database. A ListView is created to display the added contacts. An alert dialog box is

created to view an alert message when a contact is deleted.

Page 43: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

34

Figure 5.3.1: Emergency contact list and deleting a contact from the list

The Get_ContactList enables the retrieval of the contacts stored within the device. The

contacts are displayed in a ListView format with the name and associated phone numbers.

Figure 5.3.2: Retrieving contacts list

Page 44: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

35

5.4 Login:

The login into the application is handled by this class. The login can be done in two modes-

admin, user. The conditions for checking the correct username and password are done here. A toast

is displayed when an invalid credential is displayed.

Figure 5.4: Login modules

5.5 MainActivity:

This is the main class of the application where most of the features of application happen.

The MainActivity has features such as the settings dropdown menu, creation of geo-fences, clear

map button, setting the geo-fences, all of these features are hidden when a user logs in and only

display the map layout with the gesture enable checkbox and gesture message button.

Page 45: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

36

Figure 5.5.1 User login page

The sensorManager is responsible for handling the gesture implementation. The gesture

enable/disable for the user part is handled in this class.

The view from satellite to street and vice-versa are handled ad in figure 5.5.2.

Figure 5.5.2: Satellite and street view

Page 46: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

37

The geo-fences can be created using the radius entered by the user and calculating the diameter to

construct the circle.The position marked by the user is taken as a reference point or the center of

the circle and a circle with the admin mentioned values are created and each geo-fence is given a

name associated to it.

Figure 5.5.3: Creating geo-fence

When the admin/user click the back button to navigate back, they are presented with an alert box

to confirm if they want to exit. The navigation back will take the user/admin back to the login

page.

Figure 5.5.4: Alert dialog box

Page 47: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

38

5.6 Registration:

When a new user wants to create an account, the registration is done by entering few details

such as name, password, email address, phone number and address. The conditional checking is

done to check if the enter values are legal fields for each specified format. The values are also

check for duplication. If the entry already exists, a toast displaying “duplicate data” can be seen.

Figure 5.6.1: New user registration

After successful registration, an alert box appears to display that the user has successfully

registered.

Figure 5.6.2: Check for duplication

Page 48: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

39

5.7 User_locations:

In this the creation of a ListView is done to store the details of the co-ordinates received from the

user when there has been an action identified. The latitude and longitude values are stored here

along with the username given while registering.

Figure 5.7: User location retrieval

Page 49: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

40

5.8 Resources:

5.8.1 Drawable:

This folder contains the images that have been utilized in the application. The android studio

requires the images to be placed into this folder to be used in the application.

Figure 5.8.1: Drawable folder resources

5.8.2 Values:

The values folder contains the xml files for the values that we define and which can be

used repeatedly in the application. For this project a colors.xml file that defines the colors used in

the application are defined using a name and setting the hexadecimal color code to it.

Figure 5.8.2: color.xml

Page 50: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

41

The strings.xml holds the string values that appear in the application. The purpose of including the

values in these files is that for any modification , these files can be altererd rather than modifying

the code everywhere.

Figure 5.8.3: strings.xml

Page 51: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

42

6. TESTING AND EVALUATION

The testing and evaluation of the application can be performed by considering test case

scenarios, based on the results the accuracy of the application can be understood. The testing for

the application can be done by considering the different aspects of its functionalities. As the

application integrates the Google Maps API, the accuracy of the location detection would depend

on the accuracy of the integrated API. The availability of the Wi-Fi and the Cellular data also plays

a pivotal role in determining the accuracy of the location. The geo-fence created around on the

area will play a crucial role in deciding whether the person is in a safe zone or not. The context

awareness aspect of the application that detects the movements of the hand-held device will be of

key importance to trigger an alert. The possibility of the GPS being lost on the device may cause

the application feature to be deteriorated. Since the GPS of the person must be known at all time,

a proper Wi-Fi signal or Cellular data is a mandatory requirement for the application to function

properly.

The testing has been done by installing the Family Finder application on a Motorola Moto

E device with android version 5.1. For the SMS alerts to be received, another android device was

taken to check the receiving of the alert messages.

6.1 Launching the application:

When the user launches the application for the first time, the screen can be seen as in figure

6.1. The screen shows the login option and about.

Page 52: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

43

Figure 6.1 Launching the application

6.2 Login:

The user login can be done is two modes, ADMIN and USER. A new user will create an account.

The values entered while registration can be tested to see if the application accepts a non-valid

value as input.

Figure 6.2: login page of the application

Page 53: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

44

The email and phone numbers have conditions specified to meet the requirements. If not an error

can be seen as in figure 6.2.1

Figures 6.2.1: Registration values validation

The values entered must also be checked against duplication. The username once entered cannot

be registered again. These conditions for duplication have been checked and can be seen in figure

6.2.2

Figure 6.2.2: Check for data duplication

The admin will login with the pre-defined credentials, the application will show a toast saying

invalid credentials if a wrong username or password has been entered.

Page 54: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

45

Figure 6.2.3: validating credentials

6.3 Current Location:

The map activity can be tested by clicking on the current location button to check if it is

displaying the marker at the current location.

The current activity can be checked for accuracy by moving the map to another location and hit

on the current location button again.

Figure 6.3: Current location of admin

Page 55: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

46

6.4 Views:

The satellite and Street view can be switched from one to another. Upon selecting the street view

while already in street view will refresh the map.

Figure 6.4: Street and satellite views

6.5 Clear Map:

This button on the map activity is designed to clear the map by erasing all the geo-fences

and clearing the associated data. The current location is also cleared when the clear map button is

hit

Figure 6.5: Clear map activity check

Page 56: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

47

6.6 Contacts:

The application access the contacts that can be added into the emergency contact list, this

allows the added list of people to receive the alert message.

Figure 6.6 1: Viewing contacts in the phone

A contact be clicked on to add it to the emergency contact list, a dialog box will appear

asking if the contact has to be added to the emergency contact list.

Figure 6.6.2: Add to emergency contact list

Page 57: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

48

After successful addition, a toast “added” will be displayed. A contact already existing in the list

of contacts, on selection of it will display a toast “Failed to Add”.

Figure 6.6.3: Adding contact to the list

6.7 Emergency Contact List:

The emergency contact list is ListView that displays the list of contacts added. The contacts

can be deleted from this list as in figure 6.7.

Figure 6.7.1: Removing contact from the emergency contact list

Page 58: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

49

If all the contacts are deleted from the emergency list of contacts, a toast is displayed showing “No

contacts found”.

Figure 6.7.2: Empty contact list check

6.8 User Location:

The current location which is retrieved form the user account, when the user moves in/out of the

danger zone, the latitude and longitude values are retrieved and stored in this listview. The latitude

and longitude values appear with the name the user has given while registering.

Figue 6.8: Viewing user locations and clearing the list

Page 59: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

50

6.9 Creating fences:

A geo-fence can be created by clicking on the bottom button, the fencing dialog will appear where

the required conditions must be specified.

Figure 6.9.1: Creation of danger zone

When the radius field is not entered, the error can be seen in the dialog window. For a radius

entered once and cleared, the next geo-fence will create one with the already saved radius.

Figure 6.9.2: Error checking for geo-fence creation

Page 60: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

51

6.10 Message:

The message to be sent along with the latitude and longitude value can be set by the admin. This

message along with the latitude and longitude value can be seen on the receiver’s phone.

Figure 6.10: Enter message for alert

6.11 Gestures:

The gesture part is implemented on the user side, since the gestures make use of the hardware

sensors within the device, the user will have an option to enable/disable this feature. A checkbox

is provided to enable/disable the gestures. The gesture message is also set by the user to be sent

when the gesture has occurred.

Page 61: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

52

Figure 6.11: Gesture activity

6.12 Results:

The applications features are tested by creating a geo-fence with danger as the zone. For checking

the accuracy, the user enters and exits the geo-fence and the contacts added should receive the

SMS notification.

For the purpose of evaluation, I have created a geo-fence with 100 as radius and set it as danger

zone and given it a name as home. The figure shows the geo-fence created near the shores

apartments. When I moved into this danger zone, the contact listed as an emergency contacts

received a message that automatically opens up the map to display the location.

Page 62: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

53

Figure 6.12.1: Creating a danger zone geo-fence

When the contact listed in the emergency contact list receives the message, the map showing the

location retrieved is seen. The figure 6.12.2 shows the incoming message with the map displaying

the location of the user. From the timestamps, we can know that the message has been received

as soon as the user enter the danger zone.

Figure 6.12.2: Message received by the contact added to the list

Page 63: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

54

The second test-case was down by creating geo-fence near the ocean drive with a radius of 150

and danger as the zone. As the user entered the area defined by the geo-fence, the alert message

has been received by the contact added to the emergency contact list.

Figure 6.12.3: Entering a danger zone geo-fence

The next part of testing includes the evaluation of the gestures part implemented on the

user side. The gestures are implemented by the sensorManager integrating the sensor detectors

within the phone. The gestures are implemented one across the x-axis and the other across the y-

axis. The testing and evaluation of this feature is critical as there is not no control over how the

sensor detectors work in identifying the gesture. A threshold value is set for each axis and when

these values are matched the application triggers the alert message that has been set to the list of

contacts.

Page 64: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

55

Figure 6.12.4: Gesture message received by the contact added to the list.

The gestures occur in X-axis and along the Y-axis, figure 6.12.4 shows the screens that

display the occurrence of each gesture. The gestures when detected will display a toast which

shows if it is gesture X or gesture Y. The alert message will be received when these gestures have

been detected with the message set by the user.

The next test case would be to check if the battery level alert message is being sent to the

chosen list of contacts. For this purpose, the battery level of the testing device has been drained

out until it reaches 15%. As soon as the battery level of the device reaches 15% an automatic text

message is sent to the contacts added to the emergency contact list. The message content is set to

be “Battery is running low”. This message can be customized and set as per user requirements by

making alterations to the code.

Page 65: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

56

Figure 6.12.4: Battery level displayed as toast alert and Battery alert message

A test-case has been performed by admin logging into an android device and creating a

geo-fence with radius set as 100 and danger as the zone. The admin adds the required contacts who

will be received the alerts about the user locations and also set the content of the message. The

admin after performing all these activities will then logout from his account. The user will then

login to the same device, as the user keeps travelling and moving around, whenever the user’s

location is detected while entering /exiting the danger geo-fence created by admin, an automatic

alert will be triggered to the list of contacts added by the admin. The message will be received in

the form of a SMS that contains the message along with the latitude and longitude values. These

latitude and longitude values are retrieved and displayed on the map pointing the current location

of the user. The accuracy of the locations identified within the application directly depend on the

accuracy of google maps which hold an accuracy of 98.8 %.

Page 66: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

57

For the application to function well, a proper internet connection in the form of Wi-Fi or a

mobile network connection. As the application is constantly using the GPS of the device to detect

if the user lies within the danger zone it is important for the device to be connected to the internet

at all time. To test the accuracy of the application in the absence of a network connection, the Wi-

Fi and the mobile data have been turned off and the effect on the application is that, the admin will

not be able to view the maps to create geo-fences. The user capabilities of the gestures part will

work well but the location is not checked due to the absence of an internet connection. The user

even though is user entering/exiting the geo-fence will not be able to locate due to lack of internet

connection.

Feedback: The application has been tested by a group of 12-15 people who use different models

of android devices that comprises of htc, Motorola, Lenovo, Samsung etc. The following are few

the feedbacks they have provided for the application:

• The application looks good and is user friendly”

• “Useful features, drains battery”

• “excellent idea but assistance in the form of help options would make it better”

• “Nice idea. Looks good”

• “the gestures part needs to be perfect to reduce the number of alerts”.

• “Nice implementation, great scope for future work”

Based on the feedback received, the application’s features have been categorized as follows:

The scale comprises of: Bad, Neutral, Good and Excellent

Page 67: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

58

User Friendly Excellent

Portrait/Landscape Excellent

Battery Draining Neutral

Location Alerts Good

Gesture alerts Neutral

Security Excellent

Accuracy & performance Excellent

Good Wifi/Mobile network Neutral

Table 6.12: Feedback for the application

Page 68: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

59

7. CONCLUSION AND FUTURE WORK

Family finder is an application that provides new features for smartphones. by using the

built-in hardware and software sensors within the android devices, the application is capable of

providing advanced application features to the user of the device such as it lets the user create an

account during first use, which will be monitored to check if lies within the danger zone. The

admin will add the contacts who will be receiving an alert upon crossing the Danger zone (red geo-

fence). The geo-fences are created by the admin and the user’s location will be tracked to see if

they lie within the red zone; if yes, an SMS is sent to the chosen list of contacts. Since the

application is built using a local database it is capable of monitoring the location of a single user

at each time. The features provided by this application include monitoring the location and sending

the location details, making use of the sensors within the phone to detect the movement of the

device across the X and Y axis, and triggering an SMS alert when the alert has been identified.

The user can enable or disable these gestures on his device by clicking the checkbox to

select/deselect. The message will be sent to the list of contacts chosen along with the current

latitude and longitude values. The application lets the contacts be notified when the user has

crossed the vicinity of the red zone. The radius of each of the geo-fence can be modified and set

according to the user’s requirement.

FUTURE WORK:

The application developed various capabilities that will be useful in daily life. These capabilities

offered by the application can be further extended and enhanced to provide a more enriched

experience to the user. The application built has a varied scope which results in its usage in varied

situations.

Page 69: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

60

The application can be extended to provide a better user experience by incorporating the following

ideas:

The user’s current location can be monitored all the time by using live-tracking.

Live-tracking is the feature that updates the location every 5 seconds and updates the new

current location. This concept can be implemented to see as the user keeps on moving away

or towards the danger zone.

Providing multiple admin accounts so that each admin will be able to add the geo-fences

as per their requirement. The admin can be provided an option to create his/her own

credentials rather than hard-coding them into the application.

Tracking of multiple users at the same time can be a good scope of improvement for this

application. Since, the developed application is able to track only one user as it is deployed

by using SQLite as the local database. A server implementation would make it possible to

track and learn the location of multiple users.

Storing the details of the users travel pattern in the form of a map, showing the routine

routes where the user usually travel. These maps would be helpful in creating a regular

pattern followed by the user and can be used in machine learning.

The admin can be provided an option to create his/her own credentials rather than hard-

coding them into the application. By doing so the admin will have more flexibility to create

his/her login information.

Page 70: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

61

BIBLIOGRAPHY and REFERENCES

[1] J M Batalla, G Mastorakis and C X. Mavromoustakis and J urek, on cohabitating networking

technologies with common wireless access for Home Automation Systems purposes, to appear in

the Special Issue on Enabling Wireless communication and Networking Technologies for the

Internet of Things, IEEE Wireless Communication magazine 2016.

[2] Whatis.techtarget.com. (2016, Oct 22) Information about geo-fencing. Retrieved from

http://whatis.techtarget.com/definition/geofencing

[3] Human Behavior Cognition Using Smartphone Sensors L Pei 1, *, R Guinness 1, R Chen 1,2,

J Liu 1, H Kuusniemi 1, Y Chen 1, L Chen 1and J Kaistinen, 2013, 13(2), 1402-1424;

doi:10.3390/s130201402

[4] G Skourletopoulos, C X. Mavromoustakis, G Mastorakis, J Batalla and J N. Sahalos, An

Evaluation of Cloud-Based Mobile Services with Limited Capacity: A Linear Approach,

accepted/to appear to the Soft Computing Journal, Springer/Berlin-Heidelberg, 2016.

[5] MamaBear, Aug 2012, official website. http://mamabearapp.com

[6] Sygic, Family GPS Tracker, Nov. 17, 2013, Available Online at:

https://web.archive.org/web/20131117164131/http://www.sygic.com/en/family.

[7] Find My Iphone, http://www.apple.com/icloud/find-my-iphone.html

[8] ChuckGray. “A Very Brief History of Android” [Online]

http://www.librarypoint.org/android_history.

[9] Y Kryftis, G Mastorakis, C X. Mavromoustakis, J Batalla, E Pallis and G Kormentzas, Efficient

Entertainment Services Provision over a Novel Network Architecture, accepted/to appear to the

IEEE Wireless Communication magazine, July 2015

[10] C. X. Mavromoustakis, G. Mastorakis, A. Bourdena, E. Pallis, “Energy Efficient Management

using a Traffic-oriented Routing Scheme for Cognitive Radio Networks”, International Journal of

Network Management, Wiley, Volume 25, Issue 6, November/December 2015, pp. 418–434.

[11] G Skourletopoulos, C X. Mavromoustakis, G Mastorakis, E Pallis, P Chatzimisios, J M

Batalla, Towards the Evaluation of a Big Data-as-a-Service Model: A Decision Theoretic

Approach, accepted to be presented at IEEE INFOCOM session on Big Data Sciences,

Technologies and Applications (BDSTA 2016)- 2016 IEEE Infocom BDSTA Workshop, IEEE

Page 71: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

62

International Conference on Computer Communications, 10-15 April 2016, San Francisco, CA,

USA.

[12] J. M. Batalla, M. Kantor, C. X. Mavromoustakis, G. Skourletopoulos, G. Mastorakis, “A

Novel Methodology for Efficient Throughput Evaluation in Virtualized Routers”, in proc. of IEEE

International Conference on Communications 2015 (IEEE ICC 2015), London, UK, 08-12 June

2015, pp. 6899-6905.

Page 72: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

63

APPENDIX

This section contains the code snippets of the main tasks of the application.

MainActivity.java:

Page 73: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

64

Screen_one.java

ContactAdapter.java

Page 74: Design and Implementation of a Situation Aware Android Application for …sci.tamucc.edu/~cams/projects/516.pdf · 2017-05-19 · and location awareness of such smart phones, this

65

RedZoneService.java