SAVE ME – AN EMERGENCY APPLICATION A Project

advertisement
SAVE ME – AN EMERGENCY APPLICATION
A Project
Presented to the faculty of the Department of Computer Science
California State University, Sacramento
Submitted in partial satisfaction of
the requirements for the degree of
MASTER OF SCIENCE
In
Computer Science
by
Yash Shah
FALL
2013
SAVE ME – AN EMERGENCY APPLICATION
A Project
by
Yash Shah
Approved by:
__________________________________, Committee Chair
Dr. Jinsong Ouyang
__________________________________, Second Reader
Dr. Ahmed Salem
____________________________
Date
ii
Student: Yash Shah
I certify that this student has met the requirements for format contained in the University
format manual, and that this project is suitable for shelving in the Library and credit is to
be awarded for the Project.
__________________________, Graduate Coordinator
Dr. Nikrouz Faroughi
Department of Computer Science
iii
________________
Date
Abstract
of
SAVE ME – AN EMERGENCY APPLICATION
by
Yash Shah
The unusual circumstances of life threatening situations are increasing day by day for a
person who has an ordinary life. The purpose of application “Save Me” is to help the
person during the emergency times by informing the emergency contacts that are entered
in the application. The application provides different media sources through which the
user’s emergency contacts will be informed – Phone, Text Messages and Emails. The
user can enter any number of contacts that he desires to inform during the emergency
situation when the application is activated. The user can set a personal message or select
any of the pre-defined messages as their personal message. The user has an option of
changing the emails and the text messages from 1 minute (the default time interval) to
any of 30 seconds, 2/3/4/5 minutes. The user has an option of disabling means of
informing the emergency contacts – User can disable any/all of Calls, Emails or Text
Messages.
If the user has the chance of capturing a photo, the user has an option of capturing a
photo through a custom camera application that has been developed for the application
where the user can zoom in/out and also tapping anywhere on the screen will capture the
iv
image. The image will be saved in the user’s device and after that the captured image will
be emailed to all the contact emails that are entered by the user in the application. The
emails and the text messages will have the user’s device last known location i.e. the last
known nearest address (fetched from Google Maps) and the hyperlink that on
tapping/clicking will open the appropriate Maps application configured if seen on the cell
phone otherwise on computer it will open the Google Maps website with the coordinates
of the entered location. This helps the emergency contact get the driving directions or the
nearest way of reaching the user.
The application has been designed to support all the Android Operating versions from
Android 2.2 to latest Android 4.3 (API 9 – 18). The application currently has been
designed keeping the cell phones and the tablets are a part of future implementation.
_______________________, Committee Chair
Dr. Jinsong Ouyang
_______________________
Date
v
ACKNOWLEDGEMENTS
There are a lot of people that I would like to thank and acknowledge.
I would like to thank Dr. Jinsong Ouyang, my project guide, for providing me a chance to
work on this project through which I got the opportunity and exposure to wide field of
Mobile Application and especially Android application market. I would take this
opportunity to thank him for all the support and the most important necessary guidance
towards making this application perfect from a raw idea. He gave me the complete idea
about the Android application development as I was completely new when I started
working on this idea.
The next person I would like to thank would be Dr. Ahmed Salem, my second reader on
project. Under him, I got the complete idea of practical implementation of Software
Development Lifecycle which I always studied in theory and did not understand the
purpose of that thing in Software Engineering. I learnt the importance of all the diagrams
that I did not consider important at all when I learnt the topics in the class.
The next person that I would like to thank would be Mit Shah, a dear friend in India, with
whom I developed this idea on the most recent visit. I got the idea of developing Android
application from him.
vi
Last but not the least; I would like to thank my family – parents, brother and fiancé for
bearing me all through the project and not paying attention to few of their instructions.
Another special reason for thanking them would be they testing my application. They
tested my application and suggested some key feedback about the application and report
the bugs to me.
vii
TABLE OF CONTENTS
Page
Acknowledgements.............................................................................................................vi
List of Figures....................................................................................................................xii
Chapter
1. INTRODUCTION...........................................................................................................1
1.1
Background Idea .................................................................................................. 1
1.2
Purpose ................................................................................................................. 2
1.3
Brief Working of the Application ........................................................................ 2
1.4
Application Compatibility .................................................................................... 4
2. SYSTEM REQUIREMENTS..........................................................................................5
2.1 Operational Environment .......................................................................................... 5
2.2 Functional Requirements .......................................................................................... 5
2.2.1 Change Preferences ............................................................................................ 7
2.2.2 Read Information ............................................................................................... 8
2.2.3 Turn on GPS ...................................................................................................... 9
2.2.4 Capture and Email Photo ................................................................................. 10
2.2.5 Edit Contact Information ................................................................................. 11
viii
2.2.6 Activate the Application .................................................................................. 13
2.2.7 Set Notification Frequency / Personal Message .............................................. 15
3. ANDROID FRAMEWORK FOR SOFTWARE DEVELOPMENT............................17
3.1 Main Components in Android Application Development ...................................... 17
3.1.1 Activity ............................................................................................................ 18
3.1.2 Services ............................................................................................................ 20
3.1.3 Broadcast Receivers ......................................................................................... 21
3.1.4 Content Providers............................................................................................. 22
3.2 Android Application Files....................................................................................... 22
3.2.1 JAVA Files....................................................................................................... 23
3.2.2 Layout Files ..................................................................................................... 23
3.2.3 Manifest File .................................................................................................... 24
3.3 Storage Options in Android Operating System ...................................................... 26
3.3.1 Shared Preferences ........................................................................................... 27
3.3.2 SQLite Database .............................................................................................. 27
3.3.3 Internal Storage ................................................................................................ 27
3.3.4 External Storage ............................................................................................... 28
3.4 Tools Required ........................................................................................................ 28
ix
3.5 Execution of Android Programs ............................................................................. 29
3.5.1 Emulator ........................................................................................................... 29
3.5.2 Physical Device ................................................................................................ 29
4. SYSTEM IMPLEMENTATION...................................................................................31
4.1 Application Home screen ........................................................................................ 31
4.2 Enable/Disable Preferences .................................................................................... 32
4.3 Snap the Suspect ..................................................................................................... 40
4.4 Safety Tips .............................................................................................................. 45
4.5 Help – Using this Application................................................................................. 45
4.6 About Me ................................................................................................................ 46
4.7 Contact Information ................................................................................................ 47
4.7.1 Adding/Removing Contacts ............................................................................. 48
4.7.2 Choosing Notification Frequency .................................................................... 53
4.7.3 Choosing Personal Message ............................................................................ 54
4.8 Check GPS Status ................................................................................................... 55
4.9 Confirm Entered Contact Information .................................................................... 60
4.10 Application Widget ............................................................................................... 61
4.11 Content of Emails/Text Messages ........................................................................ 63
x
4.12 Application Access from Lock Screen ................................................................. 64
4.13 Future Enhancements for the Application ............................................................ 65
5. CONCLUSION..............................................................................................................68
References.........................................................................................................................70
xi
LIST OF FIGURES
Page
Figure 1. Use Case Diagram – Save Me ............................................................................. 7
Figure 2. Activity Diagram Change Preferences ................................................................ 8
Figure 3. Activity Diagram for “Read Information” .......................................................... 9
Figure 4. Activity Diagram for Turning ON GPS ............................................................ 10
Figure 5. Snap the Suspect ................................................................................................ 11
Figure 6. Activity Diagram for Saving Contacts .............................................................. 13
Figure 7. Activity Diagram for Activation of Application ............................................... 15
Figure 8. Activity Diagram for Changing Notification Frequency / Personal Message ... 16
Figure 9. Android Lifecycle for Activity .......................................................................... 19
Figure 10. Android Lifecycle for Services ....................................................................... 21
Figure 11. Android Manifest Operating System Version ................................................. 25
Figure 12. Code Snippet for Device Support .................................................................... 25
Figure 13. Android Manifest Activity .............................................................................. 25
Figure 14. Android Manifest Permissions ........................................................................ 26
Figure 15. Android Manifest Broadcast Receiver ............................................................ 26
Figure 16. Application Home Screen................................................................................ 31
Figure 17. Code Snippet for Button Click Listeners......................................................... 32
Figure 18. Calls Disabled .................................................................................................. 33
Figure 19. Calls Enabled ................................................................................................... 34
Figure 20. Emails Disabled ............................................................................................... 35
xii
Figure 21. Emails Enabled ................................................................................................ 36
Figure 22. Texts Disabled ................................................................................................. 37
Figure 23. Texts Enabled .................................................................................................. 38
Figure 24. Code Snippet for Changing Preferences.......................................................... 39
Figure 25. Custom Camera Interface ................................................................................ 41
Figure 26. Progress Bar While Saving and Emailing ....................................................... 41
Figure 27. Captured Image sent to Contacts ..................................................................... 42
Figure 28. Code Snippet for Capturing Image .................................................................. 43
Figure 29. Code Snippet for emailing Captured Photo ..................................................... 44
Figure 30. Safety Tips ....................................................................................................... 45
Figure 31. Using this Application!! .................................................................................. 46
Figure 32. About Me! ....................................................................................................... 47
Figure 33. Contact Information Layout ............................................................................ 48
Figure 34. New Contact Information Added .................................................................... 49
Figure 35. Contact Removed ............................................................................................ 50
Figure 36: Code Snippet for removing Contacts .............................................................. 50
Figure 37. Code Snippet for Adding Contacts .................................................................. 52
Figure 38. User Preference for Notification Frequency.................................................... 53
Figure 39. Personal Message Options ............................................................................... 54
Figure 40. Custom Personal Message ............................................................................... 55
Figure 41. Alert Box if GPS OFF ..................................................................................... 56
xiii
Figure 42. Device Settings for GPS .................................................................................. 57
Figure 43. Warning when user bypasses the GPS “Turn ON” Option ............................. 58
Figure 44. Code Snippet for Checking GPS Status on Device ......................................... 58
Figure 45. Code Snippet for setting the Buttons Actions for checking GPS status .......... 59
Figure 46. Prompt for Saving Data ................................................................................... 60
Figure 47. Contacts saved in Device Memory .................................................................. 61
Figure 48. Application Widget - Idle Mode...................................................................... 62
Figure 49. Application Widget - Activated Mode ............................................................ 63
Figure 50. Content of First Notification ........................................................................... 64
Figure 51. Content for the Notifications ........................................................................... 64
Figure 52. Application access from Lock Screen ............................................................. 65
xiv
1
Chapter 1
Introduction
1.1 Background Idea
During the recent trip to India, I and my friend were discussing the criminal activities
happening across the world. Lately, there is a steep increase in the criminal activities all
across the world due to some reason or the other. It implies that the safety of the
individual is decreasing day by day. Thus, we thought of developing the application that
would somehow help a person in the critical situations. When a person is in the critical or
some emergency situation, ideally he would want to inform his family members, friends
etc. Thus, we came up with the idea of developing an application that would inform
user’s contacts as soon as possible.
The main question is how to inform the contacts and that too in a timely manner. After
brainstorming for several days, I reached the conclusion that all the people ideally would
like to inform through phone or via text messages or sometimes emails. These
functionalities are present on any phone irrespective of advancement of technology, each
and every phone will have the facility to receive/dial the call or send/receive the text
messages. Emails would be available in the latest smart phone which is quite famous and
has a lot of presence amongst the people these days. Thus, I concluded that these would
be the ideal ways of informing the people about an emergency situation.
2
1.2 Purpose
The main purpose of this application is to inform the contacts that are entered by the user
in the application as soon as the user activates the application. The contacts will be
informed by the means of phone calls, text messages and Emails. These preferences can
be set by the user at his convenience and luxury. The user’s contacts will receive the
user’s device location and the nearest known address in the emails as well as the text
messages. The user can set how often they want to inform their contacts so that their
contacts get the timely information about the position of the user. In case of some event
where capturing photo is possible by user, the application provides the functionality to
the user for capturing the photo and emailing it automatically to the entered recipients in
the application. The user can set a message about informing their contacts when they are
in trouble. The application also provides the safety tips that a user can read whenever he
has free time or is not in the emergency situation.
The application gives the user, freedom of entering as many contact details that they
think are necessary for informing during the critical situations. The user can also preconfigure the frequency of how often they want to inform their contacts. The application
provides the interface where the user can turn on GPS by opening the device settings.
1.3 Brief working of the Application
The user has to enter three fields for the contact information – Contact Name, Contact
Email and Contact Phone Number. All the information will be stored in the device
memory and if the application is uninstalled or the data of the application is cleared, then
the information entered by the user will be lost. The user can enter the contact
3
information of as many numbers of contacts as he wants. The user can enter a personal
message that will be appended to the emails and the text messages. The user can select
any of the preconfigured messages that the application provides or set a custom message.
The user can set the frequency of the notifications so that they have the freedom of
choosing how often their contacts should get notified about their situation. The user can
read the safety tips provided in the application or through the application open the device
settings and turn on GPS (as it is crucial for the location coordinates).
When the application is activated, the application will check for the contact information
and if there are no contacts present then the application will open the contacts
information screen and prompt the user to enter the contacts information. If the contact
information is present, then the application will look for the preferences set by the user. If
there are no preferences selected by the user than the application will open the main
screen of the application and prompt the user to enter the preferences. If everything is in
order, then the application will load the preference and start the timer for sending the
notifications accordingly. If either of Email/Text Message is set, then the application will
get the coordinates either from the GPS or the network provider and select best location
out of it. Then based on that coordinates, it will convert into address of the nearest
location present in the surrounding based on the Google Maps Web Services. The
application will append that Location as well as make a link based on the Google Maps
and append that link in the contents of emails and text messages. So, the contact who
receives the notification can click on the link and obtain the user’s location and can reach
4
the user as soon as possible. This process will continue at the interval that is set by the
user. The user has to go into the application to stop the notifications from being sent.
The application also has widget that can be used to activate the application without going
in to the application to activate it. The widget icon will go black and white in color when
the application is active and once it is stopped or is in idle mode, the widget icon will be
colorful. If the device is latest device that runs android 4.0 or higher can create the lock
screen shortcut icon for the application to be quickly accessible.
1.4 Application Compatibility
As the application is meant to be used during the emergency or other critical situations, it
had to be made sure that the application would be compatible with most of the Android
Devices. The current version of the application can run on any Android device that runs
the Android Operating system 2.2 to 4.3 i.e. from API 9 to API 18. The application will
run only on the cellular phones. If the application is installed on the tablet, it may not
work. The user interface of the application is also kept simple for the users to understand.
It has been designed with recent trend of flat user interface.
5
Chapter 2
System Requirements
The system requirements for “Save Me – An Emergency Application” is mentioned as
under 2.1 Operational Environment
The operational environment is the environment that is required for the application to run
smoothly. This application is designed for Android Operating System. It was developed
using the Android SDK for API 17 (Android 4.2.2 – Jelly Bean). It is compatible from
Android Operating System 2.2 to 4.3 (API - 9 to API 18). Internet connection is required
in order to download the application. Internet connection is desired for this application to
work as desired.
2.2 Functional Requirements
Functional requirements are those requirements that define the scope of the project or the
application that is being designed and will be developed as the design is finalized. They
define the behavior of the application. They define the function of each component
present in the application. The functional requirements of this application can be
classified as under –

Save the Contact Information

Allow user to Set Preferences

Provide Safety Tips to User

Help – Informs the User about using the developed system
6

Allow the user to set the frequency of the contact being notified

Allow the user to enter a custom message that he wants to inform to his contacts

Turn GPS Settings ON/OFF

Capture the Photo – “Snap the Suspect”

Inform the Contacts – Upon application activation depending on the user
preferences
The whole system can be summarized in the use case diagram as Figure 1 –
7
uc Sav e Me
Save Me
Change Preferences
Read Information Safety Tips/About
Me/FAQ
Turn on GPS
User
Capture and Email
Photo
Change Contact
Information
Activ ate Application
Figure 1. Use Case Diagram – Save Me
2.2.1 Change Preferences
The user has a pool of three preferences that he can choose his preference from – Calls,
Emails, and Text Messages. He can turn ON/OFF any preference by tapping on the
toggle buttons provided on the main screen of the application. If the indicator below the
preference icon is present, it means that specific preference is ON. If the indicator is
8
missing, then the specific preference is turned OFF. When the application is installed for
the first time, all the preferences are ON by default. The user can change the preference
while the application is activated and the notifications are being sent. To understand the
flow, the diagram to represent this use case is as Figure 2 –
act changePreferences
Launch Application
Home Screen
User Selection
Calls Toggle
Button Pressed?
Yes
No
Emails Toggle
Button Pressed?
Yes
Toggle
Enable/Disable
for Calls
Toggle
Enable/Disable
for Emails
No
Texts Toggle
Button Pressed?
No
Exit
Yes
Toggle
Enable/Disable
for Texts
Exit Application
Figure 2. Activity Diagram Change Preferences
2.2.2 Read Information
The user has various options provided to him in the application where he can read the
information. The user can choose to read “How to Use the Application” or select to read
“Safety Tips” or read “About Me”. “How to Use the application” describes about the
usage of the application. Safety Tips are some important tips that the user should keep in
mind if he wants to remain safe and secure at most times. The Safety Tips are currently
fetched from the Safety Tips of Sacramento State Police Department based in California
State University, Sacramento. “About Me” section describes the thoughts and the feelings
9
that I wanted to share with the user. The equivalent features can be described in terms of
diagram as Figure 3 –
act otherActiv ities
Main Screen
User Selection
Read FAQ
Read About
Me
Read Safety
Tips
Exit
Exit App
Figure 3. Activity Diagram for “Read Information”
2.2.3 Turn on GPS
The application is very heavily dependent on two factors for obtaining the coordinates
and then the equivalent address (nearest location). The application provides an interface
for the user to turn on the GPS in the device settings. The user has to tap on “Turn On
GPS” button in the home screen of the application. Upon tapping the button, the
application will open the device settings where the user can turn ON GPS and on tapping
10
the back button, return to the application. The diagram equivalent of this can be found
Figure 4 –
act turnOnGPS
Home
Screen
Launch Application
User Selection
Exit
Turn on GPS
Open Dev ice
Settings
Exit Application
Check the
option "Use
GPS
Satellites"
Figure 4. Activity Diagram for Turning ON GPS
2.2.4 Capture and Email Photo
The application provides an interface where the user if gets a chance to capture the photo
of the surrounding situations, then he can capture that photo and send that photo to the
contact emails that are already added by the user. The camera is custom camera that is
designed for the application. The user can tap anywhere on the screen and the image will
be captured and stored on the local memory of the device. After it is stored locally, the
image will be added as an attachment and will be sent to the contact email address
entered in the application. If the contact information is not present in the application, then
11
application will open the screen where the user can enter the contact information of the
people that they want to inform about the emergency. The diagram for this use case can
be described as Figure 5 –
act snapTheSuspect
Main Screen
User Selection
Exit
Snap The
Suspect
Exit
Start Camera
Capture the
Image
Sav e Image
Contact Emails Present
No
Open
Contact
Information
Yes
Email
Captured
Image
Figure 5. Snap the Suspect
2.2.5 Edit Contact Information
This is one of the critical aspects of the application. The user will enter the contact
information of the contact that he desires to reach during the emergency/critical time. The
user has to enter three fields for the contact Information – Contact Name, Contact Email
Address and Contact Phone Number. The user has the option to enter the details of as
12
many contacts as he/she wants. The user can delete the last contact entered out of the
multiple contacts that he may have entered.
When the user tries to save the contact information, the application intelligently checks
for the status of the GPS in the device. If the GPS is OFF, then the application prompts
the user with a dialog box whether he wants to turn on GPS or not. If the user selects yes,
then the device settings screen opens and the user can turn on GPS. If the user selects no,
then the application warns the user that “GPS is the most accurate means of getting the
location coordinate which is critical to obtain the nearest address”. Now, the application
prompts the user for the confirmation of the entered data. Since, the user is manually
entering the data; there are chances that the data entered will be incorrect at time. This
action forces the user to verify the entered data and then he can tap on Yes or No button
in the dialog box accordingly. This flow of application can be described
diagrammatically as Figure 6–
13
act editContactInformation
Main Screen
User Selection
Exit
Edit Contact
Exit
Enter
Contact
Informtion
No
Information Valid
Yes
Check GPS Status
No
Turn GPS On?
Yes
Yes
Open Dev ice
Settings
Warn the
User
Confirm Data?
No
Yes
Figure 6. Activity Diagram for Saving Contacts
2.2.6 Activate the application
This is when all the aspects that are described earlier will come into picture. When the
application is activated in the emergency situation, then the contacts will be loaded from
the stored location in the device. If the contacts are not present, the application will open
the edit contacts screen where the user can enter the contact information. For using the
14
application, the user has to enter the contact information of at least one contact. Once the
determined that the contacts are present, first the preferences set by the user will be
loaded. If there are no preferences set, then the application will prompt the user for
setting the preferences. If the preferences are set, then the notifications will be generated
according to the preferences that are set by the user. If the calls are enabled, then the
dialer will be opened on the device and the contact number of the first contact will be
dialed. At that time, if the emails and the texts messages are set (all the preferences are
set by the user) the application will obtain the coordinates of the device (using Network
based location – From the cell provider (which is not accurate – Inaccuracies can go up to
100 meters) or GPS – if present on the device). The application will map the coordinates
to its nearest address using the services provided by Google. Once, the last known nearest
address is obtained, and then the application will put that information along with the
personal message that is set by the user in the email as well as the text message contents.
This process will be repeated every few minutes according to the options selected by the
user. This process will continue until the user stops the application or the device is shut
down due to some reason for example, the battery of the device is completely discharged
or by using the widget. When the application is stopped by the user, the application will
be killed from the system memory so as to avoid sending notifications. This is the same
behavior when the user activates the application using the widget.
15
act applicationActiv ated
Main Screen
User Selection
Exit
Activ ate
Application
Exit
Open
Contact
Information
No
Contacts Present
Yes
Enter and
Validate
Contact
Information
Load Contact
Information
No Preference
Set
Preferences Set?
Yes
Load
Preferences
Disabled
Calls
Disabled
Disabled
Emails
T exts
Enabled
Enabled
Enabled
Get Current
Coordinates
Call First
Phone
Number
Resolv e
Coordinates
to Address
(Rev erse
Geodcoding
Send
Notification
Application Stopped?
Repeat at User
Preference
No
Kill the
Application
Stop
Notifications
Figure 7. Activity Diagram for Activation of Application
2.2.7 Set Notification Frequency / Personal Message
The user can set how often he wants to notify his contacts. The application defaults this
to 1 minute. The user can change from to 30 seconds/2 minutes/3 minutes/4 minutes/5
minutes. The application provides an option where the user can send a personal message
16
in the notifications. The user can select any of the personal messages that are provided by
the application or they can set their own custom message. These options are available in
the application where the user can edit their contact information. The flow can be
described as Figure 8 –
act NotificationFrequency/PersonalMessage
Main Screen
User Selection
Exit
Open
Contacts
Information
OR
Exit
Change
Notification
Frequency
Change
Personal
Message
Sav e
Preferences
Figure 8. Activity Diagram for Changing Notification Frequency / Personal Message
17
Chapter 3
Android Framework for Software Development
Android is an operating system that is based on Linux Operating System that was
developed by Android Inc. and later on was brought by Google Inc. The Android
Operating system is designed for the cellular devices that are primarily touch screen
devices. Android Operating system can work from Cell Phones to Tablets to Wearable
Devices (that can be worn by a human being and could be anything like smart watch or
eye-wear or a smart camera). Android was unveiled in 2007 and the first device that had
Android Operating System was sold in 2008.
Android is an Open Source project that is released under the Apache License by Google.
The operating system being open source allows anyone to take the source code of the
application and modify the source code according to their desire. Lately, Android became
the leading operating system in the market and it became really popular among the people
due to its freedom to for customization and simple User Interface for the people to get
adapted to it.
3.1 Main Components in Android Application Development
Developing applications in Android operating system is really simple. There are four
main components that are to be considered for developing applications for the Android
operating system. They are enlisted as under –

Activity

Services

Broadcast Receiver
18

Content Provider
3.1.1 Activity
The activity component is the one where the user interacts with the application. The
entire screens that are present in the application are activity that a user does in terms of
the operating system. Thus, when a user moves from one screen to another screen, he
does an activity and from coding perspective, these activities inherit the Activity class
that is present in the Android SDK. These activities can be interrupted by the user as well
as Operating system (if the application misbehaves or goes out of control for some reason
like infinite loop or application not responding).
The life cycle of an activity can be described diagrammatically as Figure 9 –
19
Figure 9. Android Lifecycle for Activity [1]
20
When the activity is called, the onCreate method in the activity will be called. There is
option of overriding the methods that are present in the operating system. Other methods
like, onStart, onResume, onPause, onStop etc. will be executed according to the status of
the activity. When the activity is destroyed – onDestroy method will be called and then
upon the completion of the method, the activity will shut down.
3.1.2 Services
Services are the component in Android Operating System that runs in background. Thus,
all the background tasks are done using the services component. These components come
into picture the most when the application has to deal with big operations and the user are
not supposed to be kept awaiting for the process to complete for example – File
Upload/Download process, Sending email etc. This component does not provide any
User Interface.
All the services that are created in the application have to inherit the Service class
provided in Android Operating System. The diagrammatic representation of the life cycle
of Services can be found in Figure 10 as below –
21
Figure 10. Android Lifecycle for Services [1]
3.1.3 Broadcast Receivers
The component of the android operating system that responds to the system wide
broadcast of the events. This component can be used to scan whether the device display
has turned off or the device is running low on battery etc. and do the tasks as per the
situation for which the code has been developed for. This component can also be used to
design the widgets for the application where the activation of the widget may have some
22
event associated for it and thus in this case, the application will broadcast some data and
receive the same from the system notifications. For example, once the file upload process
has been completed by the user, there can be a status notification (Android Notification
Panel) that the file has been uploaded.
3.1.4 Content Providers
This component manages the shared set of application data. The application can store the
data anywhere from SQLite Database to web to any persistent storage location. Through
the content providers in the android operating system, the data stored can be modified,
queried or even store the newly entered data in the application. This component is useful
to write or read the data where the user cannot access (the protected storage on the data).
All the classes that intend to use the Content Providers must inherit the class Content
Provider class, a class in the Android SDK and use all the functions that are exposed to
enable the implementation of the transaction feature in the application.
3.2 Android Application Files
There are three files that the developer needs to take care about when developing the
Android application. They are enlisted under –

JAVA Files

Layout Files

Manifest File
23
3.2.1 JAVA Files
These files are the files where all the processing of the events that happen due to user
interaction is present. These files are the heart of the android application. All the
components those are present in the android application. This is the place where
onCreate, onStart etc. method are defined. This part is responsible for getting the user
inputs and processes the activities accordingly. Through these files, the layouts can be
added dynamically, the user entered values in the text boxes or other input can be
obtained and stored.
3.2.2 Layout Files
These files are responsible for defining the User Input. The developer can either write the
XML code for the designed interface or can drag and drop the components from the panel
and the IDE will make an equivalent XML code for the same. The user has the luxury of
seeing how the designed layout will look like in the Graphical Mode and they have the
option of selecting the device that they desire to view the layout. There are multiple
interfaces that are possible in android. Few of them are enlisted below –

Linear Layout – Using this layout option, the developer can align all the
components on the screen vertically or horizontally. This layout can be only in
one direction. This layout is usually used when the position of the components are
static and will not change during the course of the application,

Relative Layout – Through this layout, the position of the components can be
described in relation to other components. This is widely used as the position of
the components may vary based on the screen resolution on different devices.
24
This is recommended for the developers to ideally use for a large pool of devices
due to varying screen size.

List View – When there are multiple items to be displayed on the screen and they
may not fit the size of the screen, then the List View is used. The items in the list
are filled in the adapter from various sources like Database query, array etc.

Scroll View – When the components are not fitting into physical display, then the
scroll view layout is used to insert more components in the screen. A scroll view
be can scrolled vertically only. If the developer wants to use the horizontal scroll,
then there is another layout for android operating system – HorizontalScrollView.
It is not recommended to use the ListView with the scroll view as the List View
takes care of scrolling on its own.
There are more layouts available to be used in the android operating system like Frame
Layout.
3.2.3 Manifest File
It is the main part of the android application. This file contains all the information about
the application – What android operating system components are present in the
application, what permissions are required by the application etc. For using any
component, it has to be present in the manifest file otherwise that component or
functionality will not be executed when the application is installed in the device.
The manifest file defines what version of the Android Operating System, the application
is compatible with. It can defined as Figure 11–
25
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="18" />
Figure 11. Android Manifest Operating System Version
The manifest file also defines what devices that the application can support. It can
defined as Figure 12 –
<supports-screens
android:anyDensity="false"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="false" />
Figure 36: Android Manifest Device Support
Figure 12. Code Snippet for Device Support
The developer can define all the activities, their theme etc. in the manifest files as –
<activity
android:name="com.android.saveme.AboutUs"
android:label="@string/title_activity_about_us"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
Figure 13. Android Manifest Activity
The permission that the application requires for the proper execution of the
tasks/functionalities that are used in the application is declared in the manifest file. The
sample of that can be found as Figure 14 –
26
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.CALL_PHONE" />
Figure 14. Android Manifest Permissions
The broadcast receivers also have to be declared in the manifest file for the operating
system recognition. They are declared in the manifest file as Figure 15 –
<receiver
android:name="com.android.saveme.widget.SaveMeWidget"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"
/>
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/saveme_widget" />
</receiver>
Figure 15. Android Manifest Broadcast Receiver
3.3 Storage Options in Android Operating System
While working with Android Operating System, there are two options where the user data
can be stored. The options are –

Shared Preferences

SQLite Database

Internal Storage

External Storage
27
The user has the option of using any of the options depending on the need of the
application as well as the criticality of the data.
3.3.1 Shared Preferences
This mechanism stores and retrieves the data as key value pairs of the primitive data
types like String, Integer (int) or Booleans. The data stored by this mechanism will be
persisted across multiple sessions of the application. The data will remain as it is even if
the application is killed several times.
3.3.2 SQLite Database
The operating system allows the developer to use the local databases. The databases
created using the SQLite databases will be accessible to any class present in the
application. These databases have to be accessed by their names. The data will be
available across the application but not outside the application. For using this facility, the
developer has to create a subclass of SQLiteOpenHelper and override the onCreate
method.
3.3.3 Internal Storage
The operating system allows the data to be directly stored on the internal storage of the
device. The data that is stored in the file is private to the application and the other
applications that are present in the device cannot access the data stored. The user (owner)
of the device cannot also access the data of the application. When the application is
uninstalled, the files will be removed automatically from the internal storage of the
device.
28
3.3.4 External Storage
External storage can be any removable media like USB, SD Card etc. The data stored in
this storage are public and can be accessed by anyone in the application. The
user/application can read the data and have the option of modifying the data that is
present in the file.
3.4 Tools Required
Android applications can be developed across multiple IDE’s and there are several
plugins available for making the current IDE capable to write the android programs. Out
of several IDE’s, the popular IDE’s are enlisted under –

Eclipse – Any version of Eclipse can be made capable of writing the Android
Applications after installing the Android Developer Tools plugin from Eclipse
Market. Once, this is installed, the user can go the File Menu and select Android
Application as the new project.

Microsoft Visual Studio (For mono-droid programs) – This is currently not very
popular for cross platform IDE. This IDE is currently capable of writing android
programs that are based on Mono-Droid.

Android Development Tool – This IDE is provided by Google Inc. that has been
configured by the developers at Google to write the Android applications in
Eclipse. The primary IDE here is Eclipse.

Android Studio – This is the IDE that is developed by Google Inc. Currently, it
is still in the development mode and it was announced in April 2013. It is
29
currently available for free. It is based on IntelliJ software. It is available for
download across various operating systems like Windows, Mac, and Linux.
3.5 Execution of Android Programs
Once the application has been developed sufficiently that it can be tested, then there are
two options for the user to test the developed application. The user can tap on the run
button in the IDE and the application will be loaded according to the options present at
the run time. Those options are enlisted under –

Emulator

Physical Device
3.5.1 Emulator
The Android Development environment allows the developer to run the application
through the emulator. The developer can pre-configure the device that is intended for the
application to work with and then once it is ready then the user can just run the
application on the emulator. The IDE automatically installs the application on the device
and will simulate the behavior of the physical device. This will help the developer in case
they do not have a device that is running Android operating system.
3.5.2 Physical Device
If the developer has the Android operating system device, then he/she can connect the
device to the computer via USB. The developer needs to have the Developer Menu
turned on in the device for debugging the application. After the device is connected to the
computer, the user can run the application from the IDE and it will installed in the device
30
and opened automatically. This option is faster as compared to the emulator in case the
computer does not have enough resources to support emulator at high speed (considering
it is a Virtual Machine).
31
Chapter 4
System Implementation
The User Interface of this application has been designed in such a way that it will be
intuitive for the people to use the application. It has been designed keeping the Metro
User Interface (Flat UI) that is very popular these days.
Like typical other applications that require user login, this application does not require
the user to login and retrieve all information specific to the User. Since, there is an
assumption that there can be only one user who could own the device, a single user
would be using this data and hence no login information required to use this application.
The application screens are described as under –
4.1 Application Home screen
This screen appears when the user opens the application. The screen looks like –
Figure 16. Application Home Screen
32
The user can choose to do any activity from the available options. The user can choose to
open contacts and edit them or enter new contacts; he/she can start the application by
tapping on “Start Emergency button”; he/she can take the picture of the suspect by
tapping on “Snap the Suspect” button. The user can also choose to read the safety tips
provided from the application. The user can also choose preferences (what to use during
emergency times. The user can also see how to use the application by tapping on “Using
this application” button.
btnContactInfo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent openClassForEditContactIntent = new
Intent(getApplicationContext(), ContactInformation.class);
startActivity(openClassForEditContactIntent);
}
});
Figure 17. Code Snippet for Button Click Listeners
4.2 Enable/Disable Preferences
The user can enable or disable any preference by tapping on the toggle buttons for Calls,
Emails and Texts. When the application is installed for the first time, all the options will
be ON by default. The user has the ability to toggle the preferences as per his preferences.
The Icons have been provided as hint for the users – These icons are same as the one’s
found in the Android Operating System. A message (toast message) will appear on the
screen as the user turns ON/OFF the preferences. The examples for these can be found in
the following figures –
33
When the user turns OFF the preference for call, the toast message (refer to Figure 18)
“Calls Disabled” will be displayed around the bottom of the screen -
Figure 18. Calls Disabled
After disabling the calls, the user can choose to turn on the calls. For turning ON the calls
option, the user can tap on the toggle button that has symbol of “Phone”. After the user
taps on the toggle button, the toast message will be displayed around the bottom of the
screen as in Figure 19 -
34
Figure 19. Calls Enabled
The user has the option of turning OFF the Email preferences if he knows that the user
does not check the emails often. For turning the Email Preference OFF, the user can tap
on the right most toggle button on the screen. Once, it is turned OFF, a confirmation is
displayed towards that looks like Figure 20 -
35
Figure 20. Emails Disabled
If the Email previously was turned OFF and now the contact that the user has entered in
the system gets the email updates and the user wants to turn the Email preferences ON,
the user can tap on the same button that he tapped on for turning OFF the preference and
choosing not to send the email notifications. Once the preference is successfully changed,
the confirmation will be displayed on the bottom of the screen as in Figure 21 –
36
Figure 21. Emails Enabled
If the emergency contact of the user has the Text messages that are blocked or does not
receive for some reason, then the user has the option of turning OFF the Text Message
Notifications. The user has to tap on the right most icon (Icon for Messaging in Stock
Android) for turning OFF the Text Message Notification. Once the preference is
successfully changed, the confirmation for turning OFF notification will as mentioned in
Figure 22 -
37
Figure 22. Texts Disabled
If the user decides to change the contact information and now the new contact checks the
text messages and responds to them frequently, then he can choose to turn ON the Text
Message preference that was turned OFF previously. For enabling the text message
notifications, the user has to tap on the button that he tapped on for turning OFF the
preferences. Once the notification preference is turned ON the confirmation will be
shown as in Figure 23 -
38
Figure 23. Texts Enabled
The code snippet for turning ON/OFF the notification preferences is as shown in Figure
24 –
39
tglEnableTexts.setOnCheckedChangeListener(new
CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (isChecked) {
enableTexts = true;
SharedPreferences callPreferenceManager =
PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor editor =
callPreferenceManager.edit();
editor.putString("enableTexts",
Boolean.toString(enableTexts));
editor.commit();
Toast.makeText(getApplicationContext(),"Texts
Enabled", Toast.LENGTH_LONG).show();
} else {
enableTexts = false;
SharedPreferences callPreferenceManager =
PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor editor =
callPreferenceManager.edit();
editor.putString("enableTexts",
Boolean.toString(enableTexts));
editor.commit();
Toast.makeText(getApplicationContext(),"Texts
Disabled", Toast.LENGTH_LONG).show();
}
}
});
Figure 24. Code Snippet for Changing Preferences
The preference selections are stored in the local memory through the shared preferences.
When the user taps on the preference toggle button, the application stores the preference
in to the local memory of the device. The method onCheckChanged is called when the
user taps on the toggle button. The main function of this method is to determine whether
the toggle button was checked (pressed) or not. If the toggle button was pressed, then it
40
will determine whether the button was previously checked or not and do the action
accordingly (from the status of the isChecked variable).
4.3 Snap the Suspect
The user in emergency situation if gets a chance, then he can take the picture of the
suspect or whatever he/she wants to capture about the situation. The image will be store
on the device storage. It can be found under the SAVE ME directory name in the file
system of the device. As soon as the user taps on the button, a camera preview will start
and the user has the options to zoom in/out from the buttons provided on the screen or the
volume buttons present on the device. The users can use Volume Up key to zoom in and
Volume Down key to zoom out. The user can tap anywhere on the screen to capture the
image. Once, the image is captured from camera, and then the application will save the
image in the device and email it to all the contact emails that have been entered by the
user. The camera interface and the progress bar while saving and sending the emails are
designed as Figure 25 –
41
Figure 25. Custom Camera Interface
After capturing the image, the interface while saving and emailing the captured image –
Figure 26. Progress Bar While Saving and Emailing
42
After the image is sent successfully to all the members in the list, the application returns
back to the home screen with a message saying “Captured Image Sent...”. It looks like as
Figure 27 –
Figure 27. Captured Image sent to Contacts
43
mSurfaceView.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
try{
camera.takePicture(null, null, CaptureImage.this);
} catch(Exception e){
}
}
});
public void onPictureTaken(byte[] data, Camera camera) {
Toast.makeText(CaptureImage.this, "Saving File...",
Toast.LENGTH_LONG).show();
File SaveME2 = new File("" +
Environment.getExternalStorageDirectory() + "/SAVE ME");
SaveME2.mkdirs();
File suspectPhotoOutput = new File(SaveME2,
"SuspectPhoto.jpg");
FileOutputStream fosPhoto = new
FileOutputStream(suspectPhotoOutput);
fosPhoto.write(data);
fosPhoto.close();
Intent openSendPhoto = new Intent(CaptureImage.this,
SendSuspectPhoto.class);
startActivity(openSendPhoto);
}
Figure 28. Code Snippet for Capturing Image
The camera interface that is presented to the user when in taps on the Snap the Suspect
button on the home screen (Figure – 25) is a surface view when seen from the terms of
Operating System. When the user taps on the screen, the picture will be taken by the
operating system and once the picture is taken, onPictureTaken method will be called.
Since, I had to implement my own onPictureTaken method; I had to override the original
method present in the operating system. In my implementation, I save the captured image
onto the local storage present on the device. Once the image will be saved, then I will call
another activity to Email the captured image.
44
String subjectLine = "Suspect Photo";
String bodyContents = "Hello, \n\nPlease find the attached photo of the
suspect in attachment." +"\n\nPersonal Message - " + personalMessage +
"\n\nThank You.";
String fileName = MainScreen.IMAGE_STORE_PATH;
MailSettingsForAttachment sendImageSettings = new
MailSettingsForAttachment(GMAIL_ID,
GMAIL_PASSWORD);
sendImageSettings.setFromAddress("test_account@sacstate.com");
sendImageSettings.setToAddress(enteredEmails);
sendImageSettings.setMailSubject(subjectLine);
sendImageSettings.setAttachmentFileName(fileName);
sendImageSettings.setMailBody(bodyContents);
sendImageSettings.setFileName("SuspectPhoto.jpg");
try {
if (sendImageSettings.send()) {
emailSent = true;
} else {
emailSent = true;
}
} catch (Exception e) {
Log.e("mailContents", "Catch Block..", e);
emailSent = true;
}
return emailSent;
}
Figure 29. Code Snippet for emailing Captured Photo
Once the image is saved successfully in the local storage present on the device, the code
snippet presented above will load the image from the device’s local storage and add it to
the email as an attachment. Along with that other parameters for sending the email such
as to address, from address will be fetched from the user preferences stored on the device
will also be fetched. Once, everything is fetched and set, the email will be sent through
the JAVA Mail Library along with the attached photo of the suspect.
45
4.4 Safety Tips
The user can choose read the safety tips. The application has the safety tips that have
been downloaded from California State University, Sacramento’s police department.
These slides are shown all across the campus and they are useful while not on campus as
well. The user interface looks like –
Figure 30. Safety Tips
4.5 Help – Using this Application
The user can read all the help or how to use this application that he wants by tapping on
the button “Using this Application” on application home screen. The user is provided
with all the information that is required for him/her to understand this application and all
the other questions that he/she may have. The user will see a list of information as Figure
31 –
46
Figure 31. Using this Application!!
4.6 About Me
The user can choose to view the information about the author of the application. For this
purpose, the user has to open Menu from the Android Device; then tap on “About ME!”
option in the list. The representation of the user interface page can be seen in Figure 32 –
47
Figure 32. About Me!
4.7 Contact Information
The user has to enter three fields of information about the emergency contact – Name,
Email and Phone Number. The phone number can be in any format. The user has the
freedom to select how often the contacts should get his information updates; the preset
time is 1 minute. The user can set a message that will be sent in emails and texts. The
layout visuals are as Figure 33 –
48
Figure 33. Contact Information Layout
The user can tap on Save or Cancel buttons for saving the information or cancelling
information as needed. Tapping on Cancel button has no effect on the edited or entered
information (The edited/added information will not be stored).
4.7.1 Adding/Removing Contacts
The user can enter as many contacts as he/she want. User can delete already added
contacts and they will be removed from the memory where the contacts are stored. For
adding new contacts, the user has to tap on “Add More Contacts” button. Tapping on that
button the application prompts the user to enter the information of new contact. To
differentiate the contact information, the contacts are separate by a thick black line. The
visual for that aspect of the application is as Figure 34 –
49
Figure 34. New Contact Information Added
For removing the contact, tap on the remove contact button and the contact information
will be removed. In the screen visual below, the user “Shukan” (that was added newly)
disappeared after “Remove Contact” button was tapped. The remove contact button will
remove the last added contact.
50
Figure 35. Contact Removed
private void removeLayout() {
try {
if (count > 1) {
LinearLayout temp = new LinearLayout(this);
temp = (LinearLayout) findViewById(count);
addContactsLayout.removeView(temp);
count--;
} else if (count == 1) {
Toast.makeText(ContactInformation.this,"You
have to enter atleast 1 contact Info!!", Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
count++;
Toast.makeText(ContactInformation.this, "Please try again",
Toast.LENGTH_LONG).show();
}
}
Figure 36: Code Snippet for removing Contacts
Adding new contacts and removing new contacts is the process of addition and removal
of a Linear Layout dynamically. There are a few components present in the linear layout
51
that is added dynamically like Edit Texts for entering the contact information and a visual
separator in case where there are multiple contacts present on the device. When the user
chooses to remove the entered contacts, there has to be at least one contact that should be
present. Thus, when the user chooses to remove the contact, the application first validates
whether there are more contacts that are present or not. If yes, then application removes
the last layout that was added at the very last. If no, then application shows an error
message that “You need to have at least one contact present in the application.”
The code snippet for adding new contacts is as Figure 37 -
52
private void addLayout() {
count++;
LinearLayout frame = new LinearLayout(ContactInformation.this);
frame.setOrientation(LinearLayout.VERTICAL);
frame.setId(count);
for (int i = 0; i < 1; i++) {
final LinearLayout temp_ll = new LinearLayout(
ContactInformation.this);
final View lineView;
temp_ll.setOrientation(LinearLayout.VERTICAL);
LinearLayout.LayoutParams myLinearParams = new
LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
myLinearParams.topMargin = 10;
temp_ll.setLayoutParams(myLinearParams);
etNames = new EditText(ContactInformation.this);
etEmails = new EditText(ContactInformation.this);
etPhones = new EditText(ContactInformation.this);
lineView = new View(ContactInformation.this);
nameList.add(etNames);
emailList.add(etEmails);
phoneList.add(etPhones);
etNames.setId(count);
etEmails.setId(count);
etPhones.setId(count);
lineView.setBackgroundColor(Color.BLACK);
lineView.setLayoutParams(newLayoutParams(LayoutParams.FILL_PARE
NT, 10));
etNames.setInputType(InputType.TYPE_CLASS_TEXT);
etEmails.setInputType(InputType.TYPE_CLASS_TEXT);
etPhones.setInputType(InputType.TYPE_CLASS_PHONE);
etNames.setHint("Contact Name");
etEmails.setHint("Contact Email");
etPhones.setHint("Contact Phone");
if (count > 1) {
temp_ll.addView(lineView);
}
temp_ll.addView(etNames);
temp_ll.addView(etEmails);
temp_ll.addView(etPhones);
frame.addView(temp_ll);
frame.setVisibility(View.VISIBLE);
}
addContactsLayout.addView(frame);
}
Figure 37. Code Snippet for Adding Contacts
53
When the “Add New Contact” button is tapped, a linear layout is added dynamically. As
a part of that layout, edit texts for entering the contact name, email and phone number are
added. Also, there is a visual separator that is added for distinguish between the contact
information rows. After the components are added to the layout, the layout is added to the
main frame in which the user is adding the contact information.
4.7.2 Choosing Notification Frequency
The preset notification frequency set is 1 minute i.e. the contacts will be notified every
minute (For emails and text messages). The user can change it to 30 seconds, 2 minutes,
3 minutes, 4 minutes or 5 minutes. The user can choose any value from the drop down
menu. The visual for this aspect of the application is as Figure 38 –
Figure 38. User Preference for Notification Frequency
54
4.7.3 Choosing Personal Message
The user can choose a personal message that will be embedded in the email as well as the
text message. The user has the option of selecting any of the application provided options
or he can set his own custom message. If the user selects the custom message option from
the drop down menu for choosing the message, a new text box will come up prompting
user for his/her custom message. The visuals for this aspect of the application is as Figure
39 –
Figure 39. Personal Message Options
If the user selects the Custom message option, then another text box will appear as Figure
40 –
55
Figure 40. Custom Personal Message
4.8 Check GPS Status
Once the user is done editing all the contact information and other preferences, the user
has to tap on the “Save” button for saving all the changes that he made. When the user
taps on the “Save” button, the application checks if the device GPS is on. If the GPS is
on, then the application will not show the GPS alert for turning on and directly prompt
the user to confirm the entered data. If the GPS is off, then user application provides an
anchor to open the device settings and the user has the option of turning it on manually.
The visuals for this aspect look as Figure 41 –
56
Figure 41. Alert Box if GPS OFF
If the user taps on the Yes Button, then the device settings will be displayed and the user
can turn on the GPS from that screen. The settings option looks as Figure 42 –
57
Figure 42. Device Settings for GPS
If the user taps on the No Button in the alert box, then the user will be warned from the
application that looks like –
58
Figure 43. Warning when user bypasses the GPS “Turn ON” Option
These steps are necessary as the location obtained by GPS is the most accurate and this
will help the contact get the most accurate “nearest” address and it will be easily to get
the driving directions as well. The location obtained by cellular towers is not accurate and
can be inaccuracies of up to 100 meters. Thus, it is always better to use the coordinates
obtained from the GPS and not the cellular data.
public boolean isGPSOn() {
boolean gpsOn = false;
final LocationManager locationManager = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
if
(!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER))
gpsOn = false;
else
gpsOn = true;
return gpsOn;
}
Figure 44. Code Snippet for Checking GPS Status on Device
59
The purpose of this code is to determine whether the GPS Satellites are ON or not on the
device. If they are OFF, the value of the Boolean variable “gpsOn” will be set to false
and if it ON it will be set to true. This helps the application determine whether to show
the dialog box for GPS Settings or not as the GPS satellites provide the most accurate
coordinates and since the application heavily depends on the coordinate’s data, this helps
the contacts to get the most accurate location.
public void alertForTurningOnGPS() {
AlertDialog.Builder alertGPS = new
AlertDialog.Builder(ContactInformation.this);
alertGPS.setPositiveButton(R.string.txtButtonYes,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
Intent openSettingsForGPS = new Intent(
android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(openSettingsForGPS);
}
});
alertGPS.setNegativeButton(R.string.txtButtonNo, new
DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(),"Please turn on GPS for
location accuracy. It helps getting accurate "+ "coordinates when in
emergency",Toast.LENGTH_LONG).show();
UserConfirmation();
}
});
alertGPS.setMessage("Your GPS is off. Do you want to turn on
GPS?");
alertGPS.create();
alertGPS.show();
}
Figure 45. Code Snippet for setting the Buttons Actions for checking GPS status
This code snippet is for the behavior of the application if the GPS satellites are turned
OFF on the device. There are two buttons in the dialog box – Positive and Negative. The
Positive button’s task is to open the device settings as the user selects to Turn ON the
60
GPS satellites on the device. The purpose of the Negative Button is to warn and alert the
user because the user opts not to turn on the GPS Satellites on the device.
4.9 Confirm Entered Contact Information
The application forces the user to double check the entered information by prompting a
dialog box when the User taps on the Save button and the GPS dialog box is passed. The
application prompts the user with the dialog box that has the visual as Figure 46 –
Figure 46. Prompt for Saving Data
If the user taps on the No Button, then the application will be on the same screen and the
user can edit all the information and then again tap on the save button.
When the user taps on Yes, the user will be redirected to the application home screen and
a confirmation message will be shown on home screen as Figure 47 –
61
Figure 47. Contacts saved in Device Memory
4.10 Application Widget
The application provides a widget that can be added to the device main screens. The
widget icon is a ring. When the application will be activated, the color of the widget icon
will turn black and white from colored icon. When the application is not activated, the
widget icon will be in colored mode. The screenshots for the widgets in active as well as
disabled state can be found as Figure 48 –
62
Figure 48. Application Widget - Idle Mode
This is the screenshot when the widget is idle. This is conveyed by the same with the text
on the top of the widget. The size of the widget has been kept large so that it can be
accessed easily from any part of the screen if the user cannot access the phone with ease.
Once the widget is activated, the color of the ring will go out it and it will turn into a
black and white icon. This is illustrated in Figure 49 –
63
Figure 49. Application Widget - Activated Mode
4.11 Content of Emails/Text Messages
The content of the emails and the text messages is very critical considering the situation
that a person is in when the application is activated. The emails and the text messages
have the same content. The first email and text notification will inform the user (person’s
contact) to be ready and be prepared for the emergency situation that his friend/family
member is in.
64
Hello <<CONTACT USERNAME>>,
There is an emergency without contact. You'll be informed about the
location in the next email. Till then please be prepared. You should be
getting a new email with location and address within next minute or two.
Thanks.
Figure 50. Content of First Notification
After the first email is sent, the contents will contain the information about the nearest
address of the device where the application was activated, a hyper link for the location on
the Google Maps, so that it will be easy to get the driving directions to the device location
irrespective of the device whether it is being opened through a mobile client or being
accessed from the computer through the emails/text messages.
Hi!
This is a test Email. Your contact's last known location was: Sinclair Road, California
State University, Sacramento, Sacramento, CA 95826, USA. Please help your contact
in Emergency.
Personal Message from him/her: Help Me!
Contact's Location in Google Maps:
https://maps.google.com/?q=38.56139268,-121.42308511
Thanks
Figure 51. Content for the Notifications
4.12 Application Access from Lock Screen
The devices that are updated to Android Operating System 4.2.2 or higher can access the
application from the Lock Screen. The user can add the application short cut in the lock
screen and tapping on that icon will open the home screen of the application. To use this
feature, the user has to enable the lock screen widgets and applications from the device
settings options. The screenshot where the application can be added on the home screen
is as Figure 52 –
65
Figure 52. Application access from Lock Screen
To add the application from the lock screen, the user can tap on “+” for Add App and
then from the list of the available applications present on the device, the user can choose
to install the “Save Me” application.
4.13 Future Enhancements for the Application
There is always a scope for the improvements in the software that has been developed. In
Save Me, there are also quite a few places where the application can be enhanced. The
following are the immediate enhancements that can made to the application to make it
more user convenient –
66

Increase the notification Media – Presently the application allows the user to
inform the contacts through three basic media – Phone, Emails and Text
Messages. Newer media can be added for informing the contacts like updating
status on Facebook, tweeting with the location updates and some message on
Twitter etc.

Import contacts from different Sources – Presently, the application allow
importing the contact information from the “Device Contacts”. The user should be
allowed to import the contact information from multiple sources like Facebook,
Twitter, Google +, email addresses etc.

Improve Location Services – This update highly depends on the improvements
in GPS that is present on the device and the SDK provided for the Android
Operating system. As and when better methodology is available for obtaining the
Location Updates, and then the application can be enhanced to use the updated
methods so that the location obtained will be precise and accurate. Since this
application is heavily dependent on the Location of the device, this is the most
important enhancement out of the lot.

Application Activation through Hardware Keys – This is the fastest way of
activating the application as the user does not have to go into the application or
turn on the screen for application activation. Presently, for activating the
application, the user has to go into the application and activating the application.
The application can be easily activated by pressing the combination of hardware
67
keys to quickly activate application and this saves the time of unlocking the
screen and opening the application after entering the application.

Dynamic Safety Tips – Presently, the application provides safety tips from one
source. The application should be able to pull the safety information from the
multiple sources from the internet. Moreover, the feeds do not update if there are
updates in the server side. Thus, the feeds also can be made dynamic so that the
user can be present with the latest information.
68
Chapter 5
Conclusion
This application can come in real handy in any emergency or critical situations. It was
developed after noticing such cases that happened with several people especially women
all across the world. Through this application, the people who are in critical situations can
use the application and contact the concerned people. This application automates the
process of passing over the information without having to convey the briefing verbally.
Since the security of an individual is the most concerned topic all across the world, this
application is an attempt to solve such needs of the people and help them during the
emergency times.
Since mobile platform is now the most basic medium of communication these days, the
application is developed for the cellular platforms all across the world. Applications that
provide help to an individual during times where he needs help will make the life and
work of that person easier. This application will help to ease out the security concerns of
among the users and his/her loved one’s. The whole motive behind developing this
application was to add a sense of security in a life of an individual in this difficult world.
This application was developed for the devices that run on Android Operating System.
Since, this is an open source project by Google Inc., it is easy and free to download the
SDK of any version of Android Operating System. This application is compatible with
most of the devices that run on Android Operating System and are present in the market.
Since nothing is perfect in the world, this application can be enhanced with more
features. There is a scope of future enhancements for this application. Along with Phone
69
Calls, Text Messages and Emails, there can be an additional media sources in the process
of informing more and more people in a shorter span of time. The process of activating
the application can be made simpler as compared to the present implementation –
Activating the application through the Hardware keys present on the Android Device.
Presently, the application can only run on the Android Mobile Phones. Since the
popularity of the Tablets is increasing day by day, the application can also be designed
for tablets specifically. The application can also be ported on to the wearable devices that
are currently new technology in the market.
This is the foundation that I have laid for the further developments that may be possible
for this application. This is a simple effort that I have done for the security of man-kind
and providing them to relax a little in this busy life.
70
References
[1] Guide for Android Development http://developer.android.com
[2] Using system Location Services http://developer.android.com/reference/android/location/LocationManager.html
[3] Using the Camera on Device without the user intervention for confirmation http://stackoverflow.com/questions/16297606/android-take-camera-picture-without-savedelete-confirmation
[4] Using custom camera in Android http://developer.android.com/guide/topics/media/camera.html
[5] Tutorials for learning Android Operating System http://www.youtube.com/user/thenewboston?feature=watch
[6] Using ListView in Android http://developer.android.com/reference/android/widget/ListView.html
[7] Adding and Removing the Layout Dynamically http://stackoverflow.com/questions/4244889/how-do-use-the-layoutinflater-inflater
[8] Get the Data from the dynamically added Layouts http://stackoverflow.com/questions/5923587/how-to-get-data-from-each-dynamicallycreated-edittext-in-android
[9] Using Shared Preferences in Android http://developer.android.com/reference/android/content/SharedPreferences.html
[10] How to Use Shared Preferences - http://stackoverflow.com/questions/3851560/howto-use-sharedpreferences
71
[11] Saving an Array List to Shared Preferences http://stackoverflow.com/questions/7057845/save-arraylist-to-sharedpreferences
[12] Sending Emails using JAVA Mail API http://stackoverflow.com/questions/14826204/sending-emails-without-user-interventionno-intents-in-android-via-javamail-ap
[13] Sending Emails with Image as attachment using the JAVA Mail APIhttp://stackoverflow.com/questions/7604498/android-how-to-send-an-image-as-emailattachment-from-application
[14] Functionality and User of Spinner http://developer.android.com/guide/topics/ui/controls/spinner.html
[15] Checking the status of the GPS on the device http://stackoverflow.com/questions/843675/how-do-i-find-out-if-the-gps-of-an-androiddevice-is-enabled
[16] Using Alarm Manager to Schedule Events at the specific interval of time http://developer.android.com/reference/android/app/AlarmManager.html
[17] Sending Text Messages in Android http://developer.android.com/reference/android/telephony/SmsManager.html
[18] How to make calls using Android SDK http://stackoverflow.com/questions/1556987/how-to-make-a-phone-call-in-android-andcome-back-to-my-activity-when-the-call-i
Download