2. 699434/CMPRPATI
Contents
Contents................................................................................................................................................2
Introduction...........................................................................................................................................3
Wireless networks.............................................................................................................................3
Mobile telecommunications..............................................................................................................4
Mobile & Wireless applications.........................................................................................................4
Security..............................................................................................................................................5
Trends................................................................................................................................................6
Mobile Computing.............................................................................................................................6
Requirement Specification....................................................................................................................7
Mission..............................................................................................................................................7
Mobile Application.............................................................................................................................7
Database............................................................................................................................................8
Security..............................................................................................................................................8
Internet..............................................................................................................................................8
Location Based Services.....................................................................................................................8
Cloud & Sensors.................................................................................................................................8
Issues.................................................................................................................................................8
Price...................................................................................................................................................8
Permissions........................................................................................................................................9
Further Development........................................................................................................................9
Testing...............................................................................................................................................9
Maintenance......................................................................................................................................9
Design....................................................................................................................................................9
Flow Diagram of initial design............................................................................................................9
Algorithm...........................................................................................................................................9
Implementation:..................................................................................................................................10
Output Screen shots....................................................................................................................10
Summary..............................................................................................................................................12
Appendix A.......................................................................................................................................13
Appendix B.......................................................................................................................................13
2
3. 699434/CMPRPATI
Mobile Computing Review
Rebecca Patient
Introduction
In recent years, information which has been
generatedevery second of the day is
increasing. To pinpoint an exact figure is near
impossible as the volume grows rapidly and is
unlikely to stop anytime soon.
IBM produced 2.5 billion gigabytes of data
throughout 2012 in the UK alone. “About 75%
of data is unstructured, coming from sources
such as text, voice and video,".
The mobile phone technology explosion is
predicated to increase from around 61%
looking at the global population in 2013 to a
further 70% by 2017; an estimation which will
expand. In the US, the Government is using an
Open Data Project that provides over 120,000
public datasets.
Wireless networks
The wireless network is an advancement to
wired networks and fast becoming favourite
alternative because cables are not required to
connect devices within and on networks;
making for a mobile way of communicating in
business, homes and educational computer
networks.
Applied technology has been developed to
give support using wireless technology in a
variety of ways:
Types of wireless technologies:
• WIFI – Hotspot and home networks
use this technology.
• Bluetooth – Implemented in
embedded applications and low
power for instance a mobile phone or
in cars.
• Standards such as ZigBee and Z-wave.
3
4. 699434/CMPRPATI
Wireless relies on employing radio waves
and /or microwaves to maintain
communication channels between computers.
Computer hardware is needed to use wireless:
• Devices: Portability with use of
mobiles, tables which use built-in
wireless radio.
• Broadband Routers: This hardware is
wireless and supplies home networks
with a combination of other
equipment i.e. adapters and range
extenders to increase movability.
Comparative to wired networks there are
benefits but include restrictions. Mobility and
relative cable free except to a charge battery.
Drawbacks interference can occur (extreme
weather, obstructions i.e. buildings and other
devices).
There is little hardware or software which
provides secure extra security unless it’s
uploaded by the user of a device.
Mobile telecommunications
The process of sending, transmitting and
receiving information over variant distance for
the sole intention to communicate using
devices.
The transmission signal works with help of a
mobile, smart phone, tablet or any wired or
wireless technology.
Benefits are the ability to perform point to
point or point to multipoint transmissions
using digital or digitalized analog signal.
Protocols are used in a series to send packets
or blocks or information.
To actually transfer data to and from devices
depends solely on the device and data service
which is paid for:
• 4G: is becoming more of the standard,
but is still limited to only some areas
of the country. Coverage is widening
at a slow pace. The technology is the
next highest to give the most data
speeds in relation to the 3G service.
It delivers speeds of 100Mbs and
uploads of 50Mbs. Not all devices can
attain the service. However, this is
only a stepping stone to the next
stage of 5G.
The general view at present is by 2020 50
billion to 100billion devices will be connected
to the internet. This is without the thought of
cars being entered into dawn of the internet
age.
6G is thought to be developed by around
2040. The real question is what is the next big
thing to cope with such demand of 5G and
which way will technology move to next
because at present there is very little to deal
with 4G, exciting times ahead with driverless
cars and smart cities.
Mobile & Wireless applications
The mobile and wireless technologies are at
the very heart of every business IT schemes.
As technology advances so to do the business
aims. Shaping how users receive and interact
with both home and business applications
regardless of where, how and when applied.
Future developments are already in play and
performing such as google glass. Yet to really
catch on due to restrictions and a fear of is it a
step to far? Users are rapidly becoming
accustomed to these radical changes.
Designers have realised that the way forward
is to create low-cost devices and or wearables
4
5. 699434/CMPRPATI
to capture users ambitions and dreams
through challenging existing branded
technologies and highlight the design
features, how more eco-friendly and how
valuable is it to the user. Advancements
include
LED digital fashion with a click of a mobile a
dress or shirt can change colour. There are
has also been rapid movement with sensor
applications using brain patterns to change
colours on clothes, sound waves which can
make a camera move to who is speaking
rather than being pointed, there are endless
possibilities in the future.
Location based services are rapidly becoming
the new way of making money quickly in
particular stakeholders within a mobile
business organisation. There are issues with
technologies not being able to cope with the
demand of users wanting fast past
applications which require typically increased
memory and advanced storage facilities.
There are other technical issues to consider
too such as how fast can data actually travel,
human errors are a factor too looking at
interaction and behavioural patterns
(disability is a prime example, not being able
to read and dyslexia, the list is endless). All
applications are required to cover a broad
spectrum of users which means convenience
is an ongoing battle to get a balance.
They must be able to provide correct, relevant
and up-to-date information and in some cases
target a specific audience i.e. user requiring a
map to find a local restaurant or book shop. It
has to communicate instantly to users
otherwise it may be cast-off or deleted.
How best to deal with location based services
would be for the providers to home in and
utilize the highest forms of customer service
and experiences from other applications
leading to a unique advantage point through
brand, service and security.
Security
Potentially wireless networks can streamline
enterprise networking and financially viable. It
certainly is cheaper than connecting using
Ethernet cables and requiring to strip a
building to reroute a new system. Issues of
lack of network connections is severely
reduced and movability is increased.
However, control is far less than a wired
network because the data is transmitted via
cabling from device to switch, making it more
visible to the user than travelling by “air”.
Leading possibly any device being able to
capture and use without any notification to
sender or receiver. The potential is only a
300ft radius within the access point.
Threats include:
• Rogue WLANS: users may connect to
hacked wireless routers, putting the
network at risk.
• Spoofing internal Communications;
attacker connecting to the WLAN
outside; gaining trust and taking over
the device.
• Network Resources Taken: attacker
taking over the network and stealing
prime data i.e. files, accounts and
other personal information.
To protect the network, it is more advisable
to break down into sections to make it more
unattainable to attackers inside and outside
the company. Adding VLAN also offers better
security because it offers another level to
protect the internal network from attacks
which cause an issue or try and shut down the
network completely.
Firewalls or access control lists (router ACL)
can give restrictions to communications with
the WLAN and VLAN. For instance, connecting
to a WLAN on a network using the web proxy
or VPN, will give a user restricted access
permitting only usage of the internet and
possible some software and files i.e. a library
network system giving permission for Web
and Microsoft Packages.
5
6. 699434/CMPRPATI
Another way to help prevent unauthorised
users eavesdropping is to encrypt all wireless
data. WEP was the original way to encrypt but
over time holes were found and became more
of a target to attackers. It relied on a shared
key or password to gain/restrict access.
WAP was to replace WEP by using a TKIP
(Temporal Key Integrity Protocol) which
tackled the main issues WEP had been found
to have through cracking techniques and
breaking the encryption.
The latest encryption is WAP2 which is a
further development of WAP with more
complex algorithms and mechanisms, as yet
there has been no real attempt to break this
encryption but it is true at some point, an
attack will happen and cause another breach
to security.
Authentication is also a preventive step to
increase security. Providing logging and a data
trail for forensics to investigate. A thought to
giving confidentiality and integrity is a more
minor look at security compliance via risk
assessment.
The sure way to protect the network is simply
to understand all threats, risks and if attacks
happen how best to tackle security whilst a
using wireless network. More importantly
weighing up the pros and cons to ensure an
opportunist moment for a breach to occur.
Trends
There has been a recent change in the way
data is collected, no longer is there a need to
go researching. Using the cloud in conjunction
with sensors data can be formulated
anywhere and within an instance. It allows for
data to be acquired simply, applied using
visualisation i.e. graphs, monitoring where
necessary for example mission critical systems
i.e. power stations. From collated data
analyse performance and shape for a better
future.
Ubiquitous computing is also known as
persuasive computing. It is the emerging
trend leading to embedded microprocessors
within everyday living such as smart meters,
washing machines & heating systems because
allow for information to be inputted and data
outputted giving people and companies
better understanding of how we interact with
technologies.
Merging with wireless technologies,
electronics and the internet; there is big
interest from scientists, researchers, and IT
people to access the “Big Data” to make such
technologies more serviceable in every way
and in some ways to become more bespoke
to user needs. Connecting to the internet
allows for such data to be collected using the
cloud rather than face-to-face asking
questions which would be unreliable data,
whereas data is generated more readily.
Practically, smart meters work by using real-
time over the internet and reports back to the
specific energy supplier who will then be
notified if or when a shortage happens. This
means that the company can immediately
reset thermostat levels set by the user and
will send a message back to the display unit
within the home; saving both time and money
for user and the company.
Mobile Computing
This involves a wide range of portable devices
(Smartphone, Laptops & Tablets)
incorporating internet access which people
use on a daily basis for day to day living.
Such devices will use two types of wireless
access whilst moving around and away from
home. Wi-Fi being less costly, operates by
radio waves to broadcast Internet signal from
a wireless router and can move around a
specific area i.e. restaurants, libraries and
hospitals etc. If the router has not been
encrypted anyone can use it, this is better
known as a “hotspot”.
6
7. 699434/CMPRPATI
Wi-Fi can only be picked up by finding these
hotspots, leaving some unable to move from
that place until finished with the internet. The
second alternative is using cellular broadband
which uses a modem to connect to cell towers
for access. The modem is fitted into a PC Card
or slot of a device enabling the internet to
work. Unlike Wi-Fi there is not requirement to
stay stationary as the signal is consistently
strong regardless of location.
The cellular network is more expensive
because it involves premium service and
includes a cost plan depending on device and
provider. There are cases of free allowance
when connecting to the carrier’s own website
to look at personal accounts i.e. BT.
Cloud computing is new type of mobile
computing, and also the functionality of
websites from mobile computers. The cloud
gives access by implementing a type of
network environment that has countless
applications and resources. Utilizing website
resources is a far better way than to use
hardware filled with software and it’s data
with less requirement for space within homes,
offices and schools.
In addition mobile computing gives
organisations secured access using a virtual
private network (VPN) by tunnelling via the
internet. Business operations have boomed
and shaped a new way of thinking and how
they communicate with mobile computing.
Requirement Specification
The main requirements for the project are to
analyse mobile application and database.
These are the main areas from which
diagrams where created to identify the flow
of data in relation to communication. Refer to
Appendix B (1) for these diagrams.
Mission
The main aim of Free Park Application is
create a fully user-friendly android application
which can locate disabled parking spaces on
the location and be directed to use GPS and
Google maps entered by the user.
Including showing all locations, prices, charges
and allow a user to pick how many hours the
wish to stay in the space for and display the
cost.
The Project is to be developed in Java
Programming by using Eclipse Luna and ADT
Bundle. The android software development
kit SDK will be applied and gives the ability to
use a wide range of custom tools which will
help to develop the mobile application on the
android platform.
The android emulator will be the most applied
of these tools to ensure that the design is fully
functional before release.
Mobile Application
The application will require a user name and
password for security, once implementation
has been applied. When a user starts the
application a simple main page will be shown
with a welcome button.
If the user clicks the button they will be
navigated to an instructions page showing
information and contact details. From this
point the user will be able to connect to the
database where location details can be added,
deleted, edited and view data. Secondary
navigate to location information is kept with
cost of parking and charges for overstay.
This will also include a third button for more
information which will guide the user to
search the internet page – directed
www.liverpool.gov.uk for up to date
information about blue badge parking in
Liverpool, using a button to open the page.
The internet search page will also include
another button to navigate back to the main
page from where the user started on loading
the application.
This is the foundation of the application
allowing for further development enabling
7
8. 699434/CMPRPATI
those with disability and who own a car with
or without DVLA to locate, guide and park to
designated spaces in Merseyside
Database
The application will be connected to a
database to store and collect data about user
activity in terms of location details i.e. hours,
charges and precise location gaining sight into
which are the most popular locations and for
how long users wish to park there for.
SQLite Database will be implemented allowing
for SQL commands to be embedded into the
code for safety and taking control away from
the user to manipulate the application.
The database operations will be able to:
• Insert data into the database.
• Get data from the database.
• Show data into Listview: using
adapter with multiple lines.
• Delete data from the database,
Once the application is running smoothly a
count clicker will be applied to show how
much activity the application is actually is
operating and see if improvements could be
made to make it more accessible to users i.e.
adding speech to text.
Security
WAP2 will be applied and once further
developments are made to the application
then a login in screen will be added to keep
personal details secure from other users.
Validation of the code to be implemented
once the application is operational for time
purposes.
Internet
The application will be able to work on either
cellular or wireless connection. It will be
purely based on what device a user will want
to run the application on and the design could
be changed to suit individuals rather than as a
whole.
Location Based Services
At the beginning no location based services
will be added due to requiring getting the
framework started for the basic steps of the
initial design.
However, plans are ready to add google maps
and java coding at a later stage. Allowing to
learn in more detail how to apply it to the
existing project.
Cloud & Sensors
Plans to incorporate cloud facilities are
reasonable to change and update details of
new locations, gaining data more quickly and
analyse business operations.
Sensors to could be implemented to the
design by putting them onto the actual spaces
to plat and track actual usage of the spaces
set out by the council.
They could also alert when non-badge holders
are using the spaces. Perhaps, using camera
system to locate the registration plate of the
car and send out a warning letter through to
payment charges.
Issues
Possible hands-free option, tools change for
each screen, look at different colour schemes
because of disability problems?
Price
The application will be priced at £0.99p or less
depending on whether sponsorship or
advertising could be included to keep costs
down and in gain return on investment.
8
9. 699434/CMPRPATI
Permissions
Permissions will be set once the foundation of
the application is running.
Further Development
The application will have the ability to guiding
those with disability without cars to
destinations via walking and other transport
with use of an android wristwatch or mobile
device.
Other possibilities to include restaurants,
toilets and deal with where there are no stairs
allowing users to gain more of a sense of
freedom within the real world and not feel at
an disadvantage.
Book and Park System? - Time Frame applied
– Longer time given to those areas which are
under-utilized. Payment options where
required? (Coins, PayPal, credit, mobile
banking)
Testing
All testing will take place after design phase
has been checked and given the green light to
carry on for the next stages of the project.
Any issues regarding implementation will be
dealt with according from this point onwards.
Maintenance
The application will go through a number of
changes in the initial design stages and once
released the software to may change and
become obsolete. New requirements may
also be required after completion and
submitted.
Maintenance is very important because it
deals with handling all exception errors and
bugs which may exist in the system. The cost
of this is minimal as the user will get the
application at basic price and could also be
shared over a network depending how it is
applied and difficult to judge until trying to
mend it.
Design
This application uses function orientated
design approach into every module and
submodule, handling one or more functions
based on requirements made at the start.
These modules are designed and
implemented individually and combined to
form the present application.
Flow Diagram of initial design
See Appendix B for enlarged illustration of
Free Park Application (1).
Simple but most effective to create an
android application. The design also shows
the data flow process of information from a
device to the database and navigation system.
Algorithm
Free Park Design
1) User opens app to main page.
2) User clicks on Welcome button.
3) Opens parking information page.
9
10. 699434/CMPRPATI
4) User clicks on location buttons and is
navigated to location details page.
a) User chooses the location by
clicking location.
b) User inputs how many hours.
c) User clicks on cost button and
total cost appears.
d) User clicks on chargesbutton and
total charge appears.
e) User clicks on cost button and
total cost appears
5) User clicks on more info button and
navigated to the internet search page.
6) User clicks on check for updates
button. Navigated to the internet
page at www.liverpool.gov.uk.
7) User clicks back button and returns to
the main page.
8) User clicks on database button and is
navigated to database page.
a) User can create new, edit, update,
and deleted record.
Implementation:
The results of the project and screen shots for
each activity are shown with a description of
how it works. Each section is describes how
the user would interact with Free Park
Application. There are four main activities and
options and activities created on click of the
selection.
Output Screen shots
Free Park Application:
1) On load of application onto
emulator:
The icon can be clearly seen with an image of
a disability logo icon representing the Free
Park Application, on click it would open the
application which would result in the creation
of the first activity.
2) On load of activity 1: activity_main.xml
This is the first screen the user will in counter
of the project output, which has a simple
interface for the user to on click and enter the
second activity. Includes a blue badge icon for
recognition purposes.
3) On load of activity 2: parking.xml
10
11. 699434/CMPRPATI
The user is given information about how to
use the app with blue badge and gives contact
details for more questions. The user can select
a choice of going to activity 3 location details
or head to activity 5 the database and create
more location details.
4) On load of activity 3: location.xml
User can choose the location by clicking and
selecting location. User inputs how many
hours using keyboard. User can click on cost
button and total cost appears. User clicks on
charges button and total charge appears.
Output message expected, on double click of
buttons:
The third button More Info takes user to
activity 4.
5) On load of activity 4:
viewbluebadgeinfo.xml
The user is offered two buttons, the second
button navigates back to the
main_activity.xml. The first button check for
updated information leads the user to the
www.liverpool.gov.uk as shown in next screen
shot:
11
12. 699434/CMPRPATI
It clearly demonstrates the web page loading
for the user to read.
6) On load of activity 5: MainActivityDB.java
User is faced with the database interface
which will allow data to be stored and view. A
new record can be added on click of create
new record location button.
The next screen will appear:
User can type details to add to the list which
will be shown in the below location list.
Due to time constraint – testing of the
database has not been carried out so far and
means there may be issues with operations.
Time will be allotted to carry out testing and
deal with any errors which may happen i.e.
inability to make the add button insert the
inputted data on to the list and manipulate to
gain results for data analysis purposes.
Summary
All screenshots of all activities, along with the
features given to the user where shown. The
images of all icons were representational of
the Free Park Application.
The first activity has a friendly interface for
user to recognise and enter into the
application. The second activity gave
information useful to the user read and make
sense of and contact details given for any
questions raised.
The third activity parking details allowed the
user to simply decide what location and how
12
13. 699434/CMPRPATI
many hours they would park resulting in
showing total cost and charges.
The fourth activity allowed the user to check
information at the correct website to ensure
they would be fully aware of parking details in
more depth.
The fifth activity entered the SQLite database
and allowed the user to create, edit, view and
delete data from the database. Still untested
but is being giving allocated time to go back
and make changes to code where necessary
as a future improvement.
Other improvements would be to add a click
operation to count how many times the
application was used and connect the
database to the cloud enabling data analysis
of user movements. As suggested also further
development to input and direct users to their
destinations using Location Based Services
allowing to track journey routes etc.
The overall application ran as expected with
only issues dealing with the database and how
to manipulate it and gain results – which will
be undertaken as extra learning.
Appendix A
1) Anon, (2015). [online] Available at: 1)
http://www.bbc.co.uk/news/business-
26383058 [Accessed 11 Mar. 2015].
2) Anon, (2015). [online] Available at: 2)
https://catalog.data.gov/dataset/meter-rate-
schedules-58041 [Accessed 28 Feb. 2015].
3) Anon, (2015). [online] Available at:
https://www.gov.uk/government/uploads/sys
tem/uploads/attachment_data/file/265878/bl
ue-badge-scheme-statistics-2013.pdf
[Accessed 24 Feb. 2015].
4) Anon, (2015). [online] Available at: 4)
http://liverpool.gov.uk/parking-travel-and-
roads/parking-permits/blue-badge-permit/
[Accessed 26 Mar. 2015].
5) Anon, (2015). [online] Available at:
https://www.gov.uk/government/uploads/sys
tem/uploads/attachment_data/file/265878/bl
ue-badge-scheme-statistics-2013.pdf
[Accessed 24 Feb. 2015]. [Accessed 16 Feb.
2015].
6) Anon, (2015). [online] Available at: 6)
http://www.manchestereveningnews.co.uk/n
ews/greater-manchester-news/talking-digital-
manchester-uks-first-6335046 [Accessed 24
Feb. 2015].
7) Anon, (2015). [online] Available at: 7)
http://www.placenorthwest.co.uk/news/archi
ve/14316-parking-app-to-guide-drivers-in-
manchester.html [Accessed 19 Mar. 2015].
8) Anon, (2015). [online] Available at: 8)
http://www.nsl.co.uk/nsl-launches-uks-first-
major-parking-technology-trial-in-
manchester/ [Accessed 22 Mar. 2015].
9) Anon, (2015). [online] Available at: 9)
https://github.com/adamw523/Green-
Parking-Toronto [Accessed 24 Jan. 2015].
10) Anon, (2015). [online] Available at:
https://www.st-
andrews.ac.uk/itsupport/mobile/ [Accessed
19 Mar. 2015].
11) Cellbots.com, (2015). Java App |. [online]
Available
at:http://www.cellbots.com/software/java-
app/ [Accessed 28 Feb. 2015].
Appendix B
1) Free Park Data Flow Diagram:
13
16. 699434/CMPRPATI
1) Main Page
2) Parking Info
3) Location
16
Title/Logo
Image
Button
Title
Text
Buttons
Title
Text
Banner/icon
Banner/icon
17. 699434/CMPRPATI
4) Internet Search Page
17
Title
Drop Menu
(spinner)
Buttons
Textbox - Input
Image
Message of
chargers,
costs output
to user.
Title
Buttons
Image
Banner/icon
Banner/icon
18. 699434/CMPRPATI
Annotated code for Free Park
1) (Main Page) MainActivity.java
//Program: To run Free Park Android Application. Output application to user
// Illustrating the charges, costs and locations within Merseyside for
//Blue Badge Holders. Including a back-end SQLite database.
//Author: Rebecca Patient
//Date:17/03/2015
//Named package net.androidassignment.freepark
package net.androidassignment.freepark;
//Imported library
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
//Global(output to screen) MainActivity Class extends Activity
public class MainActivity extends Activity {
//Create object listView
public Object listView;
//On create of MainActivity the contentview is set in activity_main.xml
//Output to screen.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
18
19. 699434/CMPRPATI
//onclick of Button b named btnPark the activity is started and user is
// directed to Parking info.
Button b = (Button) findViewById(R.id.btnPark);
// Button b is set using onClicklistener
b.setOnClickListener(new OnClickListener(){
//Global method is visible and no return value onclick of the View.
public void onClick(View v){
//Activity is started and new intent is made from MainActivity to Parking.
startActivity(new Intent(MainActivity.this,Parking.class));
}
// End class (statement)
});
}
}
2) (Parking Information) Parking.java
//Program: To run Free Park Android Application.
// Illustrating Parking info to user with options to go to the database or to location //using onclick.
//Author: Rebecca Patient
//Date:17/03/2015
//Named package net.androidassignment.freepark
package net.androidassignment.freepark;
//Imported library
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
19
20. 699434/CMPRPATI
import android.widget.Button;
//Global(output to screen) Parking Class extends Activity
public class Parking extends Activity {
//On create of Parking the contentview is set in parking.xml
//Output to screen.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.parking);
//onclick of Button b named btnLocation the activity is started and user is
// directed to Location Details.
Button b = (Button) findViewById(R.id.btnLocation);
// Button b is set using onClicklistener
b.setOnClickListener(new OnClickListener(){
public void onClick(View v){
//Activity is started and new intent is made from Parking to Location.
startActivity(new Intent(Parking.this, Location.class));
}
});
//onclick of Button b1 named btnParkDB the activity is started and user is directed to the Database.
Button b1 = (Button) findViewById(R.id.btnParkDB);
// Button b1 is set using onClicklistener
b1.setOnClickListener(new OnClickListener(){
public void onClick(View v){
//Activity is started and new intent is made from Parking to MainActivity.
startActivity(new Intent(Parking.this, MainActivityDB.class));
}
}); // End class (statement)
}}
20
21. 699434/CMPRPATI
3) (Location Details) Location.java
//Program: To run Free Park Android Application.
//Illustrating the charges, costs and locations using simple calculation.
//Author: Rebecca Patient
//Date:17/03/2015
//Named package net.androidassignment.freepark
package net.androidassignment.freepark;
//Imported library
import java.text.DecimalFormat;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
//Global(output to screen) Location Class extends Activity
public class Location extends Activity {
//Declare variables using String,Int and double
double location = 00.50;
int numberOfhours ;
double totalcost;
String userSelect;
double charge = 02.50;
int chargehours;
21
22. 699434/CMPRPATI
//On create of Location the contentview is set in location.xml
//Output to screen.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location);
//assign variables to objects
final EditText hours=(EditText) findViewById(R.id.txtHour);
final Spinner locationArea = (Spinner)findViewById(R.id.txtLoc);
Button cost = (Button)findViewById(R.id.btnCost);
Button usercharge = (Button)findViewById(R.id.btncharge);
final TextView result = ((TextView) findViewById (R.id.txtResult));
final TextView result1 = ((TextView) findViewById (R.id.txtresult1));
//onclick of cost calculation is returned with a result with a message to the user.
cost.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
DecimalFormat currency = new DecimalFormat("£###,###.##");
//Calculation is location multiply numberofhours,hours equals total cost.
totalcost = location * numberOfhours;
numberOfhours = Integer.parseInt(hours.getText().toString());
userSelect = locationArea.getSelectedItem(). toString();
//output result
result.setText("Parking " + userSelect + " is: " + currency. format(totalcost));
}
});
//onclick of charges calculation is returned with a result with a message to the user
usercharge.setOnClickListener(new OnClickListener(){
22
23. 699434/CMPRPATI
public void onClick(View v){
//Calculation is charge multiply chargehours equals total cost.
DecimalFormat currency1 = new DecimalFormat("£###,###.##");
totalcost = charge * chargehours;
chargehours= Integer.parseInt(hours.getText().toString());
//output result
result1.setText("Charges Per Hour " + userSelect + " is: " + currency1. format(totalcost));
}
});
//onclick of btninfo user is navigated to the Internet Search Page
Button b3 = (Button) findViewById(R.id.btnInfo);
b3.setOnClickListener(new OnClickListener(){
public void onClick(View v){
startActivity(new Intent(Location.this, ViewBlueBadgeInfo.class));
}
});
}
public int getId() {
// TODO Auto-generated method stub
return 0;
}
public CharSequence getName() {
// TODO Auto-generated method stub
return null;
}}
//End Statement
4) (Internet Search )ViewBlueBadgeInfo.java
//Program: To run Free Park Android Application.
// Illustrating the internet search function with onclick and back to main button.
23
24. 699434/CMPRPATI
//Author: Rebecca Patient
//Date:17/03/2015
package net.androidassignment.freepark;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class ViewBlueBadgeInfo extends Activity {
//On create of viewbluebadgeinfo the contentview is set in viewbluebadgeinfo.xml
//Output to screen.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.viewbluebadgeinfo);
Button b3 = (Button) findViewById(R.id.btnMain);
b3.setOnClickListener(new OnClickListener(){
public void onClick(View v){
//Activity is started and new intent is made from ViewBlueBadgeInfo to MainActivity
startActivity(new Intent(ViewBlueBadgeInfo.this, MainActivity.class));
}
});
Button b4 = (Button) findViewById(R.id.btnInternet);
b4.setOnClickListener(new OnClickListener(){
public void onClick(View v){
//Activity is started and new intent is made and user is directed to www.liverpool.gov.uk
24
26. 699434/CMPRPATI
ScrollView contentView;
LinearLayout linearLayout;
ListView listView;
TextView label;
Button createNewRecordBtn;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// initiate db helper
MyDatabaseHelper dbHelper = new MyDatabaseHelper(this);
// Get records
Location[] locations= dbHelper.getRecords();
//initate layout
contentView = new ScrollView(this);
linearLayout = new LinearLayout(this);
linearLayout.setOrientation(LinearLayout.VERTICAL);
createNewRecordBtn = new Button(this);
createNewRecordBtn.setText("Create New Record Location");
// set clicklistener
createNewRecordBtn.setOnClickListener(this);
// our listview
listView = new ListView(this);
listView.setOnItemClickListener(this);
// set adapter
listView.setAdapter(new CustomArrayAdapter(this, locations));
// set labels
26
27. 699434/CMPRPATI
label = new TextView(this);
label.setText("Below Is The Location Listn' click item to delete or edit ' ");
label.setText(Html.fromHtml("<b>Below Is The Locations List</b><br><font color =
'red'><small>Below Is The Location List</small></font>"));
label.setGravity(Gravity.CENTER);
// add layout to contentview
linearLayout.addView(createNewRecordBtn);
linearLayout.addView(label);
linearLayout.addView(listView);
// set contentview
this.setContentView(linearLayout);
}
public void onClick(View view) {
// show pop up message
new PopupofUpdateorAdd(this).show();
}
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
// Get the tag
Location location = (Location) view.getTag();
// show action popup
new PopupofAction(this,location).show();
//End statement
}
}
6) (Database Connection, SQLite Commands) MyDatabaseHelper.java
//Program: To run Free Park Android Application. (Database Side)
//A helper class to manage database creation and version management
//Return the name of the SQLite database open and constructor.
27
28. 699434/CMPRPATI
//Author: Rebecca Patient
//Date:17/03/2015
package net.androidassignment.freepark;
import java.util.ArrayList;
import java.util.List;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class MyDatabaseHelper extends SQLiteOpenHelper {
// Declare variables to objects to run datanase with SQLite.
final static String DB_NAME = "my_database.db";
final static String LOCATIONS_TABLE = "locations";
final static int VERSION = 1;
final SQLiteDatabase db ;
private ContentValues locations;
public MyDatabaseHelper(Context context) {
super(context, DB_NAME, null, VERSION);
// Open database
db = this.getReadableDatabase();
}
@Override
public void onCreate(SQLiteDatabase db) {
final String CREATE_QUERY = "CREATE TABLE IF NOT EXISTS "+LOCATIONS_TABLE+
"("+
28
29. 699434/CMPRPATI
"id INTEGER primary key autoincrement,"+
"charges INT,"+
"hours INT"+
"Location TEXT"+
")";
db.execSQL(CREATE_QUERY);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// TODO Auto-generated method stub
final String DROP_QUERY = "DROP TABLE IF EXISTS "+LOCATIONS_TABLE;
db.execSQL(DROP_QUERY);
// call the oncreate method
this.onCreate(db);
}
//get records
protected Location[] getRecords(){
final List<Locations> locations = new ArrayList<Locations>();
final String SELECT_QUERY = "SELECT * FROM "+LOCATIONS_TABLE;
final Cursor cursor = db.rawQuery(SELECT_QUERY, null);
if(cursor.moveToFirst()){
do{
final Locations locations1 = new Locations();
locations1.setId(cursor.getInt(cursor.getColumnIndex("id")));
locations1.setlocation(cursor.getString(cursor.getColumnIndex("location")));
locations1.add(locations1);
}while(cursor.moveToNext());
}
// close cursor
cursor.close();
29
30. 699434/CMPRPATI
return locations.toArray(new Location[locations.size()]);
}
//insert data
protected void insert(String location){
final ContentValues values = new ContentValues();
values.put("location", location);
db.insert(LOCATIONS_TABLE, null, values);
}
//update record
protected void update(int id , String location){
final ContentValues values = new ContentValues();
values.put("location", location);
db.update(LOCATIONS_TABLE, values, "id = ?", new String[]{id+""});
}
//delete record
protected void delete(int id){
db.delete(LOCATIONS_TABLE, "id = ?", new String[]{id+""});
}
public ContentValues getLocations() {
return locations;
}
public void setLocations(ContentValues location) {
this.locations = location;
}
7) (Translation of items and the view) CustomArrayAdapter.java
//Program: To run Free Park Android Application. (Database Side)
//Translation of items and the view for bespoke Adapter using list view and text view.
//Author: Rebecca Patient
//Date:17/03/2015
30
31. 699434/CMPRPATI
package net.androidassignment.freepark;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
public class CustomArrayAdapter extends ArrayAdapter<Locations>{
Context context;
public CustomArrayAdapter(Context context,Location[] location1 ) {
super(context,android.R.layout.simple_list_item_1);
this.context = context;
}
public View getView(int position, View convertView, ViewGroup parent) {
Locations location = this.getItem(position);
TextView textView = (TextView) convertView;
if(textView == null){
// Inflate textview if null
textView = (TextView)
((MainActivity)context).getLayoutInflater().inflate(android.R.layout.simple_list_item_1, null);
}
// Set Text
textView.setText(location.getName());
//Set tag the location object
textView.setTag(location);
return textView;
}
}
31
32. 699434/CMPRPATI
8) (Method) Locations.java
Methods need looking at to reason perhaps why database is non-fully-functional, time to be allotted
to look at issues.
//Program: Methods for running Free Park Android Application.
//Author: Rebecca Patient
//Date:17/03/2015
//named package net.androidassignment.freepark
package net.androidassignment.freepark;
////Global Locations (output to screen)
publicclass Locations {
//simple objects created
publicclass Location {
//assign id, name to String and int.
privateintid;
private String name;
//global get ID
publicint getId() {
// return value id
returnid;
}
//global no return value of set Id to int.
publicvoid setId(intid) {
this.id = id;
}
public String getName() {
returnname;
}
publicvoid setName(String name) {
this.name = name;
32
33. 699434/CMPRPATI
}
}
publicCharSequence getName() {
// TODO Auto-generated method stub
returnnull;
}
publicvoid add(Locations location) {
// TODO Auto-generated method stub
}
publicvoid setId(intint1) {
// TODO Auto-generated method stub
}
publicvoid setlocation(String string) {
// TODO Auto-generated method stub
}
//End of Methods
}
33