developing google android mobile clients for web …

45
DEVELOPING GOOGLE ANDROID MOBILE CLIENTS FOR WEB SERVICES _______________ A Thesis Presented to the Faculty of San Diego State University _______________ In Partial Fulfillment of the Requirements for the Degree Master of Science in Computer Science _______________ by Sri Tulasi Peddola Spring 2012

Upload: others

Post on 29-Nov-2021

3 views

Category:

Documents


0 download

TRANSCRIPT

DEVELOPING GOOGLE ANDROID MOBILE CLIENTS

FOR WEB SERVICES

_______________

A Thesis

Presented to the

Faculty of

San Diego State University

_______________

In Partial Fulfillment

of the Requirements for the Degree

Master of Science

in

Computer Science

_______________

by

Sri Tulasi Peddola

Spring 2012

iii

Copyright © 2012

by

Sri Tulasi Peddola

All Rights Reserved

iv

DEDICATION

I would like to dedicate this thesis to my parents, who have been an everlasting

source of inspiration in my life. I would not have been able to achieve what I have without

their support.

v

ABSTRACT OF THE THESIS

Developing Google Android Mobile Clients for Web Services by

Sri Tulasi Peddola Master of Science in Computer Science

San Diego State University, 2012

Web Services, which is a popular implementation of Service Oriented Architectures (SOA), have been outstanding for years as the leading technology in the Distributed Computing world reached its third generation. The importance of web services facilitates the need in now a day’s Mobile phones to have the ability of consuming and accessing Web Services. Web Services is nothing but an implementation of the Service Oriented Architecture as it in evolves distributed systems, describes the general architecture and some standards involved in it. These services utilize SOAP protocol.

Earlier we have expenses tracker application with local database, in this project Developing Google Android Mobile Clients for Web Services [4], users can save his personal data on his mobile. If the mobile crashes or mobile lost there is no way to take the back up of the data. So if the mobile data is saved in some centralized location the user can save or backup his data even if the mobile is lost or crashed. This is not the only one advantage of this, as we have the centralized database, the development architecture is different. Here we are maintaining SOA, which means once if we have a web service in remote server with centralized database then we can use the same web service for different clients either it may be Android, iPhone, Blackberry, Windows phone, Bada, Java phones, Symbian phones, etc. Different clients can use the common web service to save or retrieve the data. We can also take backup/restore the database from database end. For this to implement the main resource needed is Internet Information Server (IIS) Web Server. For this SOA process the current database MS SQL Server database can also be replaced by other databases like MySQL, Oracle, Postgre, etc.

Building an Android application that runs on mobile phones for tracking expenses. The application will store data locally and as well as on the server using web services. Users can enter expenses using the app like name of the expense, category of the expense, amount spent, date, etc. Users can view expenses both in table form and in graph form. This application provides flexibility to users by calculating monthly, yearly and as well selected category wise budget. Many people are unaware of costs and waste scarce resources. Expenses tracker is the way to calculate the total costs of purchasing and utilization of the product and helps to control and reduce costs to plan for the future in regards to the budget. The main goal of implementing this project is to support Google Android mobile platform as client, thereby demonstrating its main features, design and architecture and illustrating the importance of Android mobile platform relationship with Web Services.

vi

TABLE OF CONTENTS

PAGE

ABSTRACT ...............................................................................................................................v

LIST OF TABLES ................................................................................................................. viii

LIST OF FIGURES ................................................................................................................. ix

ACKNOWLEDGEMENTS ..................................................................................................... xi

CHAPTER

1 INTRODUCTION .........................................................................................................1 1.1 Short Notes on Expense Tracker........................................................................1 1.2 System Analysis .................................................................................................1 1.3 Existing System .................................................................................................2 1.4 Proposed System ................................................................................................2 1.5 Characteristics and Key Features of the Proposed System ................................3

2 LITERATURE ...............................................................................................................4 2.1 Mobile Platform .................................................................................................4

2.1.1 What is Android ....................................................................................... 4 2.1.2 Android Components ............................................................................... 4 2.1.3 Activity .................................................................................................... 4 2.1.4 Services .................................................................................................... 4 2.1.5 Intents ....................................................................................................... 5 2.1.6 Content Providers..................................................................................... 5 2.1.7 Broadcast Receivers ................................................................................. 5 2.1.8 Applications ............................................................................................. 6 2.1.9 Tools ........................................................................................................ 6

2.2 Android Application Features ............................................................................6 2.3 Setting Up the Android Environment ................................................................7

2.3.1 Using DDMS ........................................................................................... 7 2.3.2 Installing the ADT Plug-In for Eclipse .................................................... 7 2.3.3 Creating an AVD ..................................................................................... 7

vii

2.3.4 Steps to Install the Android Environment in Eclipse ............................... 8 2.4 Android Versions and Project Directory Structure ............................................8

2.4.1 Android Versions ..................................................................................... 9 2.4.2 Android Project Directory Structure ........................................................ 9 2.4.3 Units of Measurements .......................................................................... 10 2.4.4 Important Attributes of XML Views ..................................................... 10

3 DESIGN SPECIFICATION ........................................................................................11 3.1 Use Case Diagrams ..........................................................................................11

3.1.1 Expenses Use Case Diagram ................................................................. 11 3.1.2 Show Expense Use Case Diagram ......................................................... 12

3.2 Expenses Class Diagram ..................................................................................12 3.3 Expenses Sequence Diagram ...........................................................................13 3.4 Expenses Collaboration Diagram ....................................................................14 3.5 Data Flow Diagram ..........................................................................................15 3.6 Tabular Form of Representation of the Database Fields .................................15

4 IMPLEMENTATION ..................................................................................................19 4.1 System Requirements.......................................................................................19 4.2 Implementation of the Expense Tracker ..........................................................19 4.3 Usage of Expense Tracker Application with Web Services ............................20 4.4 Steps to Configure the Project .........................................................................21 4.5 Web Services Overview ...................................................................................21

4.5.1 Main Features of Web Services ............................................................. 22 4.5.2 Major Advantages and Known Challenges of Web Services ................ 22 4.5.3 Major Organizational Challenges Addressed by Web Services ............ 23

4.6 Android Application Development by Consuming .Net Web Services ..........23 4.6.1 Requesting SOAP Web Service ............................................................. 23 4.6.2 Calling the Service ................................................................................. 24

5 GRAPHICAL USER INTERFACE ............................................................................25 6 DISCUSSION ..............................................................................................................33

6.1 Future Enhancements .......................................................................................33 6.2 Conclusion .......................................................................................................33

BIBLIOGRAPHY ....................................................................................................................34

viii

LIST OF TABLES

PAGE

Table 3.1. Function Names: Expenses Table ...........................................................................17 Table 3.2. Function Name: Category Table .............................................................................18

ix

LIST OF FIGURES

PAGE

Figure 1.1. Existing system architecture. ...................................................................................2 Figure 1.2. Proposed system architecture. .................................................................................3 Figure 3.1. Use case diagram for creating expenses. ...............................................................11 Figure 3.2. Show expense use case diagram. ...........................................................................13 Figure 3.3. Expenses class diagram. ........................................................................................14 Figure 3.4. Expenses sequence diagram. .................................................................................14 Figure 3.5. Expenses collaboration diagram. ...........................................................................15 Figure 3.6. Data flow diagram for the application. ..................................................................16 Figure 5.1. Homepage. .............................................................................................................25 Figure 5.2. Creating a new expense and entering the details for the expense. ........................25 Figure 5.3. Setting up the date. ................................................................................................26 Figure 5.4. Newly created expense is saved successfully. .......................................................26 Figure 5.5. Displaying the created expenses in table and R-graph form. ................................27 Figure 5.6. Listing the expenses in table form. ........................................................................27 Figure 5.7. Displaying expenses for whole year. .....................................................................27 Figure 5.8. Displays amount spent in each month. ..................................................................27 Figure 5.9. Total expenditure for the selected month. .............................................................28 Figure 5.10. Select a particular month to display monthly expenses. ......................................28 Figure 5.11. Displaying expense categories and amount spent in a month. ............................28 Figure 5.12. Category wise listing the expenses. .....................................................................28 Figure 5.13. All expenses under office supplies category is shown. .......................................29 Figure 5.14. Graphical representation for a selected category. ................................................29 Figure 5.15. Graph for selected category. ................................................................................29 Figure 5.16. Graph for expenses spent throughout whole year. ..............................................29 Figure 5.17. Retrieving the information stored in the database. ..............................................30 Figure 5.18. Hosting the web service in the remote server using IIS. .....................................30 Figure 5.19. Application is loaded using the web service which is hosted in the server. ........31

x

Figure 5.20. Inserting a new category by running the application locally. ..............................31 Figure 5.21. Displays all the expenses for whole year. ...........................................................32 Figure 5.22. All the expenses saved throughout the whole year are displayed. ......................32

xi

ACKNOWLEDGEMENTS

I would like to express my heartfelt gratitude to Dr. Joseph Lewis and Carl Eckberg

for giving me the opportunity to work on this project and for providing constant support and

motivation. I would also like to thank Professor Moon Song for serving on my thesis

committee.

I would also like to thank my dad, mom, grandparents, and my entire family for the

sacrifices they made to help me attend graduate school. I am very grateful for all their

support and motivation that they have provided for the past two years.

1

CHAPTER 1

INTRODUCTION

1.1 SHORT NOTES ON EXPENSE TRACKER Suppose consider a person who doesn’t possess a simple and easy mechanism by

which he can control the flow of the amount spent on the expenses per month or per year.

This application provides the most important feature by which the above mentioned problem

can be addressed i.e., it allows the users to keep track of their money monthly and yearly

wise which in turn serves best to get an idea of all the different kinds of expenses. It will

allow users to create new expense, show expense details, and add categories to the database.

This application allows you to track money spent on all your daily or monthly or annual

expenses. It provides a quick way to track expense, income and bookkeeping purposes.

Expenses Tracker is great application for managing your expenses and it is a simple way to

manage your personal finances. Internet Access is used to save and retrieve expenses from

Mobile. We can take database backup and restore.

1.2 SYSTEM ANALYSIS As discussed in the abstract the existing system has no security in terms of

maintaining the database or to take the backup. There is no centralized protection to the

database. If the mobile crashes or mobile lost there is no way to take the back up of the data.

Some of the features that expenses tracker posses are:

1. Expenses Tracker is a simple and friendly and intuitive expenses tracking application which focuses more on helping manage individuals finance.

2. It easily creates your own category and sub-category of the expenses eventually which helps in Organizing your categories

3. This application also provides an easy way to Generate reports which Tracks and analyzes spending with customizable reports.

You can use Expenses Tracker to:

• track personal expenses

• track travel expenses

2

• track entertainment expenses

• track income

• track club collection

• track project expenses

• track bills

• track investment portfolio

1.3 EXISTING SYSTEM In the current system configuration, data will be stored inside the Mobile phone in

SQLite Database (see Figure 1.1). If we want to save the data in a common place, i.e.,

Remote Server until now there is no easy mechanism to implement this. The need for storing

information in remote server exists because even if the mobile is lost or stolen you can get

back all the expenses data stored inside the phone. The idea of storing information in remote

server is implemented using Web Services which can save the data in the Remote database

like SQL Server.

Figure 1.1. Existing system architecture.

1.4 PROPOSED SYSTEM The proposed mobile application is completed based on Service Oriented

Architecture (SOA) where we have thin clients like Android Phones, iPhones, etc. Services

are self contained and communicate using messages like xml. They are cross platform,

asynchronous, reliable and secured. SOA is an architectural style for building business

applications using loosely coupled services which act like black boxes and can be

Android phone SQLite

3

orchestrated to achieve a specific functionality by linking together which you can see in

Figure 1.2. Once we have a web service in remote server with centralized database then we

can use the same web service for different clients either it may be Android, iPhone,

Blackberry, Windows phone, Bada, Java phones, Symbian phones, etc. Different clients can

use the common web service to save or retrieve the data. We can also take backup/restore the

database from database end.

Figure 1.2. Proposed system architecture.

1.5 CHARACTERISTICS AND KEY FEATURES OF THE PROPOSED SYSTEM

Characteristics and key features of the proposed system are as described below:

For Organizations: It is a quick handy way to track expense, income, mileage, sales,

receipts for tax reimbursement and bookkeeping purposes.

For Day to Day Life: It helps in monitoring cash flow, balance available in a

particular month from anywhere and at any time.

User-Extendable Database: User can add income/expense categories. We can take

database backup and restore.

Android phone Web Service Database

4

CHAPTER 2

LITERATURE

2.1 MOBILE PLATFORM Mobile platform is an operating system for mobile devices. Some of the mobile

devices operating systems are iOS, Bada, Android, Windows, and Blackberry, etc.

2.1.1 What is Android Android is a software pile for mobile devices which includes an operating system,

middleware components and other key applications. The Android SDK facilitates the APIs

and tools needed to start developing applications on the Android platform. For Developing

applications in Android the programming language used is Java programming language.

2.1.2 Android Components These are some of the Android components which are the major means by which

Android application runs successfully without any interruptions.

2.1.3 Activity Android activity is represented by each individual screen within an Android

application. User can interact with activity by performing some actions which involves visual

components. Example of an activity can be considered as a single webpage in a website.

Each activity performs its operations independently of one another and all the activities in the

application are an extension from the activity class.

2.1.4 Services Service is another component in Android application which performs its actions in the

background to accomplish actions which take long time to run or remote processes tasks.

Service is a component which does not possess user interface. Consider an example where

service can play music in the background when the user is performing some operation in

other application like checking an email or texting a message using SMS application or

5

retrieve some information from the network without interrupting user’s actions within an

activity

2.1.5 Intents Intent is an application which initiates the message passing between the activities.

Using intents messages can be broadcasted throughout the system or if it can also pass

messages to a target activity or service, which states intended action requested by the user or

activity. Specifying an Intent-filter allows a user to state how a particular activity in an

application should be called.

2.1.6 Content Providers A content provider is a component which maintains a collective group of application

data. All the application information or data can be stored in a SQLite database or file

system, on remote web servers or on any storage location where the application can access

the data. Using the content provider, other applications can process its queries and other

related activities. This component mostly behaves like a database where users are given

flexibility to edit its contents, query information needed, delete some data when not needed.

The only difference between database and content provider is that using content provider

users can store its data in different ways.

2.1.7 Broadcast Receivers This component responds to system wide broadcast declarations. Any application

which needs to receive or respond to global activities like SMS application, receiving an

incoming call, it should have been registered as a broadcast receiver. Most of broadcasts

come from the system for example, we can consider a broadcast statement like when battery

is low it shows red colored battery symbol in the phone, when screen lock button is pressed

the display will be turned off, when SMS is received its shows a message symbol at the top

of the notification bar. Broadcast receivers doesn’t possess user interface for broadcasting

notifications instead they alert the users by showing the status of the application in the

notification bar.

6

2.1.8 Applications All the Android packages by default comes with a bunch of core applications which

includes an SMS application, Email application, calendar, maps, browser, contacts, GPS and

others. All these applications are developed using the Java programming language.

2.1.9 Tools The Android SDK is Software Development Kit which allows developers to develop

mobile applications in Android platform. Generally these tools are categorized into two

groups, they are SDK tools and platform tools. Among these SDK tools are independent of

the platform and these are mandatory for any mobile application which are developed in

Android platform. The second most common tools are Platform tools which are modified or

personalized to provide support to the latest Android platform features.

2.2 ANDROID APPLICATION FEATURES Android offers several application features out of which the following mentioned

features are the most effective and useful characteristics of Android applications:

• The Dalvik Virtual Machine has been upgraded to improve developing mobile devices applications framework enabling reuse and replacement of components.

• GSM the Global System for mobile communications kind of telephony has been introduced.

• A productive application framework has been developed which enables the application components to be reused and replaced.

• Open source web kit has been integrated in the browser.

• Custom 2D and 3D graphics libraries came to the market which are based on Open GL specification.

• Structured data storage is supported by using SQLite database.

• All the audio, video and image formats are supported in the new Android versions like MPEG, MP3, JPG, GIF, PNG and ING.

• Hardware supportive environment like Wifi, 3G, 4G, EDGE connectivity and Bluetooth are improved in the Android platform.

• Development environment has been made popular by introducing device emulator feature Camera, GPS, compass, and accelerometer (hardware dependent).

7

• All other important features include accelerometer, camera, GPS, several different tools which helps in debugging the application, memory management and performance monitoring.

2.3 SETTING UP THE ANDROID ENVIRONMENT Android Development environment can be set in any machine using Eclipse IDE. To

develop an Android application the following tools must be installed in Eclipse [1].

2.3.1 Using DDMS Android ships with a debugging tool called the Dalvik Debug Monitor Server

(DDMS), which provides port-forwarding services, screen capture on the device, thread and

heap information on the device, log cat, process, and radio state information, incoming call

and SMS spoofing, location data spoofing, and more.

2.3.2 Installing the ADT Plug-In for Eclipse To install the ADT plug-in in Eclipse we need to click on Help button at the top of the

eclipse window then select Install New Software [1]:

• Click on add button in the Available Software dialog box.

• In the next dialog box enter the name for remote site for example ADT plug-in the “Name” field.

• Need to enter this URL in the Location field: https://dl-ssl.google.com/android/eclipse.

• Once this is done you should be able to see Developer Tools added in the list under the Available Software view. Click next by checking the box next to the Developer Tools.

• In the Installation progress dialog box you should see the Android DDMS and Android Development Tools features. Read and accept the license agreement, later install all other dependencies by clicking Finish button. Once installation is done restart Eclipse.

• Configure the ADT Plug-in by going into ADT preferences tab in Eclipse and browse to the Android SDK directory then click apply and OK.

2.3.3 Creating an AVD To configure the real world devices in an Android Emulator this Android Virtual

Device (AVD) is used. To run the emulator and display Android device in that we need to

create an AVD in the Eclipse [2].

8

The following steps must be followed to create an AVD from Eclipse:

• Open Eclipse and go to Window toolbar and click on Android SDK and AVD Manager.

• A list of already existing AVDs will be shown under the Virtual Devices panel. Select the New button to create a new AVD.

• To create a new AVD some of the details must be given like name of the AVD, intended target platform, the size of the SD card and select HVGA as default skin.

• While defining a target for the AVD make sure that the application’s Build Target API level should match with compiling application API.

• After clicking on create AVD don’t forget to enable the Internet access permission to the mobile application that you are working on.

2.3.4 Steps to Install the Android Environment in Eclipse

The following steps describe the procedure to install Android SDK and ADT plug in

in the Eclipse IDE which enables users to view the Android applications in an emulator from

the machine:

1. Download and Install Java Platform (JDK)

2. Download Eclipse IDE for Java Developers

3. Download the Android SDK Tools

4. Update the Android SDK

5. Configure Eclipse with Android Development Tools (ADT) and Update the Developer Tools

6. Update the Android SDK path by selecting windows preferences and add SDK path in Eclipse

7. Create Android Virtual Device (AVD) or Emulator

8. Set the Class path for Android SDK and Java

2.4 ANDROID VERSIONS AND PROJECT DIRECTORY STRUCTURE

The following sections describe the current and the upcoming versions of Android

software. Also Android project directory structure and Android attributes of the XML view

are also described.

9

2.4.1 Android Versions Google introduced several different versions of Android Operating System. These are

some of the android versions which evolved as updates to the previous versions.

2.0/2.1 (Eclair), which enhanced the user interface and brought into existence a new

feature HTML5, W3C Geolocation API and Exchange ActiveSync 2.5 support

2.2 (Froyo), introduced speed improvements with JIT optimization and the Chrome

V8 JavaScript engine, and added Wi-Fi hotspot tethering and Adobe Flash support

2.3 (Gingerbread), which refined the user interface, improved the soft keyboard and

copy/paste features, and added support for Near Field Communication [3].

3.0/3.1 (Honeycomb), a tablet-oriented release which supports larger screen devices

and introduces many new user interface features, and supports multicore processors and

hardware acceleration for graphics.

3.2 (Honeycomb), which is similar to 3.1 but optimized for 7-inch tablets.

4.0 (Ice Cream Sandwich), a combination of Gingerbread and Honeycomb into a

“cohesive whole.” It was announced on May 10, 2011 at Google I/O that it will be released

in Q4 2011.

2.4.2 Android Project Directory Structure SRC is folder under com.packagename in filename.java file which consists of all the

source code for the particular project

Gen is a folder under com.packagename in R.java file

Assets – Assets is a directory in Android application which consists of the assets

extensively used by some of the applications like Databases, Text files and HTML etc

Res – Resource is a folder which contains all the resources used in the application

such as layout, raw, menu, anim, values, color, xml, drawable-hdpi, drawable-mdpi, and

drawable-ldpi.

Androidmanifest.xml: This is a manifest file which consists of Package name, version

code, version name, application image, name of the application, activity information, intent

filter, Android: minSdkVersion and permissions [4].

XML File (UI of Android Activity) <?xml version=“1.0” encoding=“utf-8”?> <LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”

10

android:orientation=“vertical” android:layout_width=“fill_parent” android:layout_height=“fill_parent”> <TextView

android:text=“row one” android:textSize=“15sp” android:layout_width=“fill_parent” android:layout_height=“wrap_content”

/> </LinearLayout>

2.4.3 Units of Measurements Most of the web pages are designed in pixels but when pixel ratio is used there are

some problems with the increased screen resolution. In order to avoid this problem android

supports the following units of measurement.

DP or Dip: Dip is abbreviated as Density Independent pixel where 160dp is

equivalent to one inch of physical screen size.

SP: SP is abbreviated as the Scale Independent Pixel which is recommended for

specifying font sizes in the Android application.

2.4.4 Important Attributes of XML Views These are some of the most widely used attributes in Android applications which

helps in better XML views of a screen in the application.

xmlns:android: This is an XML namespace declaration that tells the Android tools

that you are going to refer to common attributes defined in the Android namespace. The

outermost tag in every Android layout file must have this attribute.

android:id: This Attribute can be used as the assigned ID which behaves like a

reference View from the source code or from other XML resource declarations.

android:layout_width: This attribute defines how much of the available width on the

screen this View should consume

android:layout_height: The attribute layout_height refers to the available screen

height for the application.

android:text: This particular attribute sets the text alignment in which Text View of

the application should be.

11

CHAPTER 3

DESIGN SPECIFICATION

3.1 USE CASE DIAGRAMS The architecture of the application is explained using Unified Modeling Language

diagrams.

Unified Modeling Language (UML) [5] provides IT professionals with a common

design format to build and develop computer applications using the design view of the

application. Use Case diagram in Figure 3.1 demonstrates the functionality of each individual

unit in the system. These diagrams help in better visualization of the functional requirements

which includes the relationship between actors and the use cases.

Figure 3.1. Use case diagram for creating expenses.

3.1.1 Expenses Use Case Diagram This is the use case diagram for Expenses Tracker application. Here user is provided

with three different options of which are create new expense, show expense and add

category. When user selects create new expense it will allow them to create a new expense

like laptop, furniture, books, insurance, etc. Show Expense is the field which displays the

Show Expenses

Data Base

Create New Expenses

Add Category

User

12

output of the selected categories and expenses both in Table and R-Graph form, there is a

database connected to the show expense field so that when ever user requests for some

information the request will be sent to the database, query will be processed and then later it

sends the response back to the application. Add Category is the field which will allow users

to create a new category for the expenses like office supplies, leasing, business loans,

transportation, etc.

3.1.2 Show Expense Use Case Diagram In Figure 3.2 Use Case Diagram for Show Expenses Field is shown. When user wants

to see the output of the created expenses through whole year or for a particular month this

field will provide the necessary information. In the Table form of the display there are four

sub sections namely Expense list, Total Expense per month, Expense per selected month,

Expense List Category which helps in displaying the output monthly expenses spent, yearly

expenses created and category based expenses spent. In the similar way R-graph also

displays all the information from the database in the graphical form so that it will be easy for

users to keep track of the money flow throughout year or for a particular month as well.

3.2 EXPENSES CLASS DIAGRAM Figure 3.3 explains the class diagram for the Expense Tracker application. It consists

of four classes namely Mobile Application, Web service, Search criteria and Database. Each

one of these classes has their own role in contributing to the project work flow:

1. Mobile application class consists of methods like add category, create new expense and search method which invokes an object in the Search Class when user requests for some information.

2. Web service class consists of methods like getExpensedata, getCategoryData, InsertExpenseData and insertCategoryData. All of the user requests will be received by web service using SOAP protocol it forwards the request to the Database and receives the response back from the database and which gives the resultant information back to the mobile application.

3. Search class consists of only two methods Request and Response but these methods play a major role in transferring the information from the application to the database and back from the database to the application which uses web service to search for the information in the database.

13

Figure 3.2. Show expense use case diagram.

4. Database is the class which consists of methods like getData and insertData which helps in receiving the information from the application, stores the information in the database and returns back the information when user request is made.

3.3 EXPENSES SEQUENCE DIAGRAM The Sequence diagram for Expenses Tracker application is explained in Figure 3.4.

Here whenever user requests to creates a new expense, add categories those details will be

inserted from the application into the database, whereas the database stores all the expense

details created by the user, once the request is processed it returns back the desired output to

the application. In the application User Interface, the results will be displayed both in

Table form and R-Graph form.

Tables

R-Graph

Total Expense Per Month

Show Expense

Expense List

User

DataBase

Expense Per Selected Month

14

Figure 3.3. Expenses class diagram.

Figure 3.4. Expenses sequence diagram.

3.4 EXPENSES COLLABORATION DIAGRAM Figure 3.5 is the Collaboration diagram which depicts that whenever user enters

new expenses details by adding categories and expenses, the application stores the

information in the database and returns the expense details to the application. User will

be able to see the output in the application where the information is displayed in Table and

R-Graph form.

User: Application DataBase

Creates new Expenses and adding categories and inserting detailsStores user expense details in the database

Gives the details of the Expenses

Shows the details to the user in the form of Tables and R-Graph

15

Figure 3.5. Expenses collaboration diagram.

3.5 DATA FLOW DIAGRAM In Figure 3.6 Data Flow Diagram for the Expenses Tracker application is shown. The

application starts with three fields like Create New Expenses, Show Expenses and Add

Category. Suppose a user wants to create a new expense for this month he can do that using

this field by entering the details. He can also add new Categories to the application using the

field add category which prompts the user to enter desired category name. To retrieve back

the stored expenses from the database user can select show expenses category by which he

can view the result in both Table form and R-Graph format.

3.6 TABULAR FORM OF REPRESENTATION OF THE DATABASE FIELDS

Table 3.1 shows the functionality that allows the user to create New Expenses and to

view the details of the Expenses. Table 3.2 shows the functionality that allows the user to add

the Category.

User: Application

DataBase

1: Creates new Expenses and adding categories and inserting details

2: Stores user expense details in the database

3: Gives the details of the Expenses

4: Shows the details to the user in the form of Tables and R-Graph

16

Figure 3.6. Data flow diagram for the application.

Start

Add Category

Create New Expenses

Show Expenses

Shows Tables and R-Graphs Enter the details of

Expenses

Enter the Category Name

Stop

17

17

Tab

le 3

.1. F

unct

ion

Nam

es: E

xpen

ses T

able

Sr N

o.

Nam

e of

Attr

ibut

e D

escr

iptio

n M

anda

tory

V

alid

atio

ns

1 Ex

pens

e ID

U

ser i

s exp

ecte

d to

ent

er th

e Ex

pens

e ID

Y

es

(1) C

anno

t be

null.

2

Cat

egor

y na

me

Use

r is e

xpec

ted

to e

nter

the

Cat

egor

y na

me

Yes

(1

) Can

not b

e nu

ll.

3 Ex

pens

e na

me

Use

r is e

xpec

ted

to e

nter

the

Expe

nse

nam

e Y

es

(1) C

anno

t be

null.

(2

) Can

not c

onta

in n

umer

ic v

alue

s. 4

Dat

e In

put

Use

r is e

xpec

ted

to e

nter

the

Dat

e In

put

Yes

(1

) Can

not b

e nu

ll.

5 A

mou

nt

Use

r is e

xpec

ted

to e

nter

the

Am

ount

Y

es

(1) C

anno

t be

null.

U

ser

Inte

ract

ion

and

Syst

em In

tera

ctio

n Fi

elds

O

pera

tion

Use

r In

tera

ctio

n Sy

stem

Inte

ract

ion

Err

or/W

arni

ng?

Mes

sage

N

ew

(1) U

ser w

ill b

e ab

le to

read

the

new

Ex

pens

es d

etai

ls.

(1) S

yste

m sh

ould

gen

erat

e ne

w

Acc

ount

. (2

) It s

houl

d cr

eate

a n

ew re

cord

and

sa

ve it

in d

atab

ase

with

a su

cces

s m

essa

ge a

nd S

ave

the

Cre

ated

det

ails

.

“Rec

ord

save

d su

cces

sful

ly.”

Mod

ify

(1) U

ser w

ill b

e ab

le to

mod

ify th

e de

tails

usi

ng th

is o

ptio

n.

(1) S

yste

m sh

ould

upd

ate

mod

ified

ac

coun

t in

data

base

with

succ

ess

mes

sage

. (2

) Upd

ate

the

Mod

ified

det

ails

.

“Rec

ord

save

d su

cces

sful

ly.”

Get

AllE

xpen

seD

ata

(1) U

ser w

ill b

e ab

le to

get

the

Expe

nse

Dat

a

Get

Expe

nseD

ataF

or

Cat

egor

yNam

e (1

) Use

r will

be

able

to g

et th

e Ex

pens

e D

ata

for t

he C

ateg

oryN

ame

Get

Expe

nseD

ataF

or

Sele

cted

Mot

hWith

Tota

l (1

) Use

r will

be

able

to g

et th

e Ex

pens

e D

ata

for t

he se

lect

ed m

onth

with

tota

l.

18

18

Tab

le 3

.2. F

unct

ion

Nam

e: C

ateg

ory

Tab

le

Mai

n Fu

nctio

nal A

reas

Sr N

o.

Nam

e of

Attr

ibut

e D

escr

iptio

n M

anda

tory

V

alid

atio

ns

1 C

ateg

ory

ID

Use

r is e

xpec

ted

to e

nter

the

Cat

egor

y ID

Y

es

(1) C

anno

t be

null.

2

Cat

egor

y na

me

Use

r is e

xpec

ted

to e

nter

the

Cat

egor

y na

me

Yes

(1

) Can

not b

e nu

ll.

Use

r In

tera

ctio

n an

d Sy

stem

Inte

ract

ion

Ope

ratio

n U

ser

Inte

ract

ion

Syst

em In

tera

ctio

n E

rror

/War

ning

M

essa

ge

New

(1

) Use

r will

be

able

to re

ad th

e ne

w

mob

ile fe

atur

es.

(1) S

yste

m sh

ould

gen

erat

e a

new

A

ccou

nt.

(2) I

t sho

uld

crea

te a

new

reco

rd a

nd

save

it in

the

data

base

with

the

succ

ess m

essa

ge.

(3) S

ave

the

“Mod

ified

” an

d “C

reat

ed”

deta

ils.

“Rec

ord

succ

essf

ully

save

d.”

Mod

ify

(1) U

ser w

ill b

e ab

le to

mod

ify th

e de

tails

us

ing

this

opt

ion.

(1

) It s

houl

d up

date

mod

ified

acc

ount

in

dat

abas

e w

ith su

cces

s mes

sage

. (2

) Upd

ate

Mod

ified

det

ails

.

“Rec

ord

succ

essf

ully

save

d.”

Get

AllC

ateg

oryD

ata

(1) U

ser w

ill b

e ab

le to

get

all

the

cate

gory

dat

a.

19

CHAPTER 4

IMPLEMENTATION

4.1 SYSTEM REQUIREMENTS These are minimum system and software requirements which serve best in

developing Android applications using the Android SDK.

Supported operating systems include:

• Windows Vista or XP (32 bit or 64 bit)

• OS: Android version 2.2 and 2.3

Supported development environments:

• Eclipse 3.5 (Galileo)

• Android SDK Tool

• Eclipse ADT

• USB Driver for Windows (to check the output in Android Phone)

Hardware requirements include:

• Android Mobile or Android Emulator

4.2 IMPLEMENTATION OF THE EXPENSE TRACKER The Expense Tracker application is implemented with the .Net language web service

using KSOAP2 Library in Android. For information storage and retrieval of the data, used

the SQL Server 2008 database to create tables maintain data in the database. This application

needs Internet connectivity in the Mobile phones to work better with web services. Consider

a user needs to retrieve some information from the application then the user request will

initiate a query inside the mobile application, which in turn sends a request to the web

services using Request and Response methods in the SOAP protocol those requests will be

processed and when the requested action is completed it sends a response back to the mobile

application. For example suppose user requested to create a new category or a new expense

under a particular category, the request is sent to the mobile application first and then to the

remote database using the web service calls, after querying the input the web server

responses back with the message saying “Expenses created successfully” (row inserted). In

20

the same way if we consider an example to Get All the Categories created throughout the

whole year the application returns all the categories in the database using a web service that

is hosted in Internet Information Services (IIS).

4.3 USAGE OF EXPENSE TRACKER APPLICATION WITH WEB SERVICES

Expense App Communicates with the server using the web service URL which is

hosted in the web service (IIS) at remote location. We can add this URL at only one location

i.e., in values/strings.xml file.

The communication is achieved using a KSOAP2 library. Using KSOAP2 the

Android app gives SOAP requests to the web server, the web server responses back with the

data for the query to the mobile application. The ksoap2 is an efficient and lightweight SOAP

library for the Android platform.

Most of the kSOAP2 [6] library has been tested keeping in mind about the Android

platform .This library also has lots of upgrades which adds more features and enhancements

and continuously works on fixing bugs and contributions. Whenever new features are

included in the library they release that software regularly.

The web server communicates with the databases like MS SQL Server, MySQL, and

Oracle, etc. Currently in this application we are using MS SQL Server, in future if we want to

change the database we can change the database with few changes in the web service. The

database is maintained centrally where we can take backups and restore it.

To construct this complete architecture of the application the following software’s

needs to be installed:

1. Install the Java JDK environment

2. Download Eclipse and update with Android Debugging Tool

3. Download and update Android SDK (Update Android SDK by clicking sdkmanager.exe inside SDK folder)

4. Install SQL Server 2008

5. Install Visual Studio 2010

6. Install the IIS Server

7. Host the web service in IIS

8. Refer the URL in the Expenses App

21

9. Consume the web service using KSOAP2 methods inside the expenses Tracker mobile application.

4.4 STEPS TO CONFIGURE THE PROJECT To set up the Development environment for this application. The following

software’s and tools must be installed:

1. Create a database using SQL server 2008 or other with the name Expenses and in the database create two new tables namely Category table and Expenses table as shown in the Figure 5.17 (see Chapter 5, page 30).

2. Use Visual Studio 2010 to Open the Web Service Project and the database connection string values should be set in Data Access Layer (DAL) for this project there are two DAL layers which are Expenses DAL and Category DAL. The database connection string values can be given using connection string method in which data source, catalog, and User Id and password fields should be set.

3. Host the Web Service using Internet Information Services in Windows 7 or Windows XP platform.

4. In the Android Application, navigate to res/values/string.xml file and give the URL of the hosted web service. Example:

<string name=“URL”>http://192.168.1.2/Expenses/ExpenseWebService.asmx</string>

5. Right click on the Expenses project, click on properties, then navigate to Java Build Path and add the following two jar files by clicking on Add External JAR button.

Android Plot jar file and ksoap2 jar file which is present in External JAR folder inside the project

6. Now users can insert some data into the category and expenses table using Android application or Web services local host, the data inserted into the application will be stored in the database and check the application using Android User Interface.

4.5 WEB SERVICES OVERVIEW The main purpose of Service Oriented architecture [7] is accessing services of

software components by heterogeneous consumers in the Internet. There are many other

models other than SOA, which are strongly related to enterprise, where as SOA mainly deals

with integrating applications and also departments for the company [8].

Recent technologies like COBRA, MOM, .NET, J2EE can also be used with SOA to

develop interface, which can deploy it on a server and be used by the client. Than any other

technology implemented by SOA model, Web Services has emerged as the best due to its

highest independence level. This is also for a reason, that Web Services is a self describing

22

application that projects the business logic over the Internet through programming interfaces

and also using Internet Protocols in order to invoke these services. From a functional point of

view, using web services is very beneficial as these enable application to application

communication and this is making it easier accessing applications from the devices over the

Internet, where as old traditional web based applications interact between the user and the

website. The base and purpose for choosing this is because of standard protocols and data

formatting.

4.5.1 Main Features of Web Services In web services all the data will be exchanged using XML format (extensible Markup

Language):

• The integration of the applications over the internet is supported in multiple platforms

• Web services are not language dependent, i.e., web services features can be utilized using any programming language.

• As Web services utilize standard protocols like HTTP it makes the application access all the resources easily through firewalls.

• It provides broad range of features, functionalities and clients which varies from a small request to complex requests or services.

• Almost all of the Platforms varying from .NET, J2EE and CORBA comfort deployment of Web Services.

• Any application which uses web services can dynamically invoke public and private registries using the standard protocols like UDDI and ebXML.

4.5.2 Major Advantages and Known Challenges of Web Services

The most important advantages and challenges of using web services in an

application are as follows:

• The application will be hosted in the remote server using web services there by increasing the feasibility and availability of the application from anywhere by anyone and from any device.

• Application will be implementing Service-based architecture which encourages intra-enterprise and inter-enterprise communication.

• Some of the organizations who require smoothness and flexibility in an application can utilize web services to support better inter application communication over the Internet.

23

• The most important benefit of using web services is that any new application can be merged with existing application to bestow with collective Web services.

4.5.3 Major Organizational Challenges Addressed by Web Services

Web services addresses the following challenges which are possessed by most of the

organizations in the recent times [9]:

• Security: Web services feature is utilized in almost all of the applications where information storage and retrieval communication should be achieved in remote applications. So highly secured protocol standards like HTTP, SSL, UDDI must be implemented which uses the most effective authentication and authorization mechanisms to encrypt the messages between the applications. Since most of the applications are open to public the best solution would be to include these security standards like SAML, XML Encryption, and XML Signature in applications.

• Distributed transactions: The developing environment should be tested and studied appropriately using these standard solutions so that the application environment can utilize the feature of distributed transactions within multiple resources.

• Quality of Service (QoS). For any kind of business critical application, quality of service of the application must be carefully examined by the service provider so that under peak load and unexpected conditions the applications performance and reliability should be stable. Application should be able to provide load balancing and fault tolerance even in unstable situations.

The Other kind of challenges like manageability and testing the applications in

different operating system environments and platforms are also addressed by Web services

deployment in an application.

4.6 ANDROID APPLICATION DEVELOPMENT BY CONSUMING .NET WEB SERVICES

Android Mobile application requests the web service with parameters, receiving the

response and parsing it to obtain data. We use KSOAP2 protocol to consume .Net Web

Services.

4.6.1 Requesting SOAP Web Service Web services process the inter communication between application and database

using SOAP protocol [10]. A SOAP protocol consist of three components under it namely

SOAP request/response, Header and Body.

24

SOAP Request/Response is sent as a SOAP Envelope which consists of a SOAP

Header and a SOAP Body.

SOAP Header: It is a component of the soap envelope which is optional and mostly

contains the information which is specific to the application. Example of such information in

soap header is the authentication mode which we specify for any application like read, write,

etc. It contains a SOAP Action which helps in identifying the required functions to be called

by the service.

SOAP Body: Soap body consists of the actual message which is sent to the service

and acknowledgment received from the service.

4.6.2 Calling the Service To call the SOAP [11] web service the following procedure must be applied.

First construct the SOAP envelope following the standards mentioned in the Soap

protocol.

As soon as the function is called the response will be in a String format. This

response message should be parsed again to extract the data which is the output of the

application.

25

CHAPTER 5

GRAPHICAL USER INTERFACE

I would like to present screenshots for the expenses tracker application. When the

Android application starts it will load the project and displays the home page. In the first

screen of the application the user is provided with three categories like create new expense,

show expense and add category. The sub categories under these sections are briefly depicted

in the following screenshots.

Figures 5.1 through 5.4 describe the sections that need to be filled to create a new

expense and once expenses is created it displays a message as expenses saved successfully.

Figure 5.1. Homepage. Figure 5.2. Creating a new expense

and entering the details for the expense.

26

Figure 5.3. Setting up the date. Figure 5.4. Newly created expense is

saved successfully.

Figures 5.5 through 5.13 demonstrate displaying the information in table view. In the

table view expenses per month, per year and for selected category are shown in the figures.

Figures 5.14 through 5.16 display the graphical representation of the data for a selected

category and for whole year. Figures 5.17 through 5.22 demonstrate setting up the database

and hosting the web service in the remote server to store and retrieve the data from the

server.

27

Figure 5.5. Displaying the created expenses in table and R-graph form.

Figure 5.6. Listing the expenses in table form.

Figure 5.7. Displaying expenses for whole year.

Figure 5.8. Displays amount spent in each month.

28

Figure 5.9. Total expenditure for the selected month.

Figure 5.10. Select a particular month to display monthly expenses.

Figure 5.11. Displaying expense categories and amount spent in a month.

Figure 5.12. Category wise listing the expenses.

29

Figure 5.13. All expenses under office supplies category is shown.

Figure 5.14. Graphical representation for a selected category.

Figure 5.15. Graph for selected category. Figure 5.16. Graph for expenses spent

throughout whole year.

30

Figure 5.17. Retrieving the information stored in the database.

Figure 5.18. Hosting the web service in the remote server using IIS.

31

Figure 5.19. Application is loaded using the web service which is hosted in the server.

Figure 5.20. Inserting a new category by running the application locally.

32

Figure 5.21. Displays all the expenses for whole year.

Figure 5.22. All the expenses saved throughout the whole year are displayed.

33

CHAPTER 6

DISCUSSION

6.1 FUTURE ENHANCEMENTS The current database MS SQL Server database can also be replaced by other open

source databases like MySQL, Oracle, Postgre, etc.

This project is developed as a beginner application for expenses tracker. It can be

further developed to provide a richer user interface. Expenses saved can be emailed to all

family members when needed.

In the application user interface there is no way to delete or modify expenses created.

This can also be implemented as future enhancement.

The web service feature implementation is shown only in Android phones which can

also extended to Blackberry phone, Windows phone, Symbian phones, iPhone, etc.

6.2 CONCLUSION The goal of implementing this project is to support Google Android mobile platform

as client, thereby demonstrating its main features, design and architecture and illustrating the

importance of Android mobile platform relationship with Web Services. By using Android

SDK and Eclipse IDE as the development environment the application is built keeping in

mind about the design standards and maintainability of the code.

This application is very simple to use and helpful to record all the expenses both

locally inside the phone and as well as on the server using web service.

34

BIBLIOGRAPHY

[1] Google Inc. ADT Plugin for Eclipse, 2011. http://developer.android.com/sdk/eclipse-adt.html, accessed Jun. 2011.

[2] Mihira Prasanna. Step by Step Procedure to Access Web Services from Android, 2010. http://www.codeproject.com/KB/android/webservice-from-android.aspx?display=Print, accessed Jun. 2011.

[3] Wikipedia. Android Operating System, 2011. http://en.wikipedia.org/wiki/Android_%28operating_system%29, accessed Jul. 2011.

[4] Vito Daniele. Developing Google Android Mobile Clients for Web Services, 2007. http://www.mobilab.unina.it/tesi/TESI_V.D.Cuccaro.pdf, accessed Jul. 2011.

[5] Donald Bell. An Introduction to the Unified Modeling Language, 2003. http://www.ibm.com/developerworks/rational/library/769.html, accessed Nov. 2011.

[6] Google Inc. kSOAP2-Android, 2011. http://code.google.com/p/ksoap2-android, accessed Jul. 2011.

[7] Object Innovations. Web Services Using C# and ASP.NET, Rev. 2.1, 2007. http://www.objectinnovations.com/CourseOutlines/418.html, accessed Aug. 2011.

[8] W3 Schools. Introduction to Web Services, 1999. http://www.w3schools.com/webservices/default.asp, accessed Oct. 2011.

[9] Rob Howard. Web Services with ASP.NET, 2001. http://msdn.microsoft.com/en-us/library/ms972326.aspx, accessed Oct. 2011.

[10] FeedBurner. All about Web Service in .Net, 2007. http://dotnetguts.blogspot.com/2007/09/all-about-web-service-in-net.html, accessed Jul. 2011.

[11] Sacoskun. Consuming .NET Web Services via kSOAP Library, 2010. http://www.sacoskun.com/2010/02/consuming-net-web-services-via-ksoap_07.html, accessed Oct. 2011.