- •Introduction
- •External apIs
- •Connecting to public apIs
- •Interacting with soap services
- •2 Creating a mobile application for os Android
- •2.1 Eclipse
- •2.2 Web Server
- •2.3 Php and json
- •2.4 Java
- •2.5.1 The use case diagram
- •2.5.2 The sequence diagram
- •3 Implementation of the project
- •3.1 Architecture of application
- •3.2 Description of the classes
- •3.2.1 MainActivity.Java
- •3.2.2 Register.Java
- •3.2.3 Login.Java
- •3.2.2.1 Description of the functions and variables of the class Register.Java
- •3.2.5 Call.Java
- •3.3 Php scripts
- •3.4 Xml files
- •3.5 User's Guide to the application's
- •4. Economic Part
- •4.1 Economic efficiency
- •4.2 Android Market
- •4.3 Calculation of the costs of developing software
- •4.3.1 Calculation of the cost of materials
- •4.3.2 Expenditure on salaries
- •4.3.3 The costs of operation and maintenance of equipment
- •4.4 Calculation of profit
- •5 Health and life safety
- •5.2 Analysis of dangerous and harmful factors
- •5.3 Production sanitation and health
- •5.4 Electrical safety
- •5.5 Fire safety
- •5.6 Safety precautions when working with a computer
- •5.7 Calculation of artificial light and noise workplace laboratories "nit"
3.2.5 Call.Java
This class uses when user selects Call without backup. In this page user can see all his contacts and his phone number. When presses to one of the contacts application will automatically call to this contact.
protected void onCreate (Bundle savedInstanceState) - it is a function of the main interface for querying
public void onClick (View v) - this function starts when you press the button Button, and if the entered information is correct, sends the information to the database and logs the user
public void onPreExecute () - this function creates a PDialog and shows until the program receives data from the Base
protected String doInBackground (String. .. args) - main function is to register
protected void onPostExecute (String file_url) - sends data to the interface
Table 6 – variables of class Call.java
Name |
Type |
description |
jsonParser |
JSONParser |
To send information to the base |
Submit |
Button |
If the information entered is correct, sends the information to the database and logs the user |
Phone |
String |
phone number contact |
name |
String |
phone name of contact |
Reg |
Button |
Button registration |
Login |
Button |
Button for login |
List |
ListView |
List of all contacts |
Pho |
TextView |
List of phones |
url |
String |
URL php script |
Success |
Int |
For validation |
PDialog |
ProgressDialog |
Animation boot |
Login |
String |
User login |
Ok |
Boolean |
To verify the correct password |
Ko |
Boolean |
To check the stored contacts |
3.2.6 JSONParser.java
This class is used for connection with application and php scripts. Application gives parameters and this class converts this to comfortable json format and opens http connection. And sends information to server and receives from server.
Description of the functions and variables of the class JSONParser.java
public JSONObject makeHttpRequest(String url, String method, List<NameValuePair> params) – in JSONParser.java only one method. This method has three parametres: String url is used for getting for what address will send this information, String method is used to know method of connection Get or Post, List<NameValuePair> params is parameters to send.
Table 6 – variables of class JSONParser.java
Name |
Type |
description |
Is |
InputStream |
For saving InputStream |
jObj |
JSONObject |
For saving object of JSON |
Json |
String |
For saving json |
method |
String |
For knowing what kind of method |
httpClient |
DefaultHttpClient |
For saving httpclient |
httpPost |
HttpPost |
For saving httpPost |
httpResponse |
HttpResponse |
For saving HttpResponse |
httpClient |
DefaultHttpClient |
For saving DefaultHttpClient |
paramString |
String |
All parameters |
reader |
BufferedReader |
Reading from stream |
line |
String |
One line of stream |
In Figure - 9 you can see the class JSONParser.java for example of one class
public class JSONParser {
static InputStream is = null;
static JSONObject jObj = null;
static String json = "";
// constructor
public JSONParser() {
}
// function get json from url
// by making HTTP POST or GET mehtod
public JSONObject makeHttpRequest(String url, String method,
List<NameValuePair> params) {
// Making HTTP request
try {
// check for request method
if(method == "POST"){
// request method is POST
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}else if(method == "GET"){
// request method is GET
DefaultHttpClient httpClient = new DefaultHttpClient();
String paramString = URLEncodedUtils.format(params, "utf-8");
url += "?" + paramString;
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
line = reader.readLine();
sb.append(line + "\n");
is.close();
json = sb.toString();
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
// try parse the string to a JSON object
try {
jObj = new JSONObject(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
// return JSON String
return jObj;
}
}
Figure 9 - JSONParser.java