
- •Introduction
- •Mobile Android platform
- •In addition, it was reported that Google will, at its discretion, remove applications on phones users if developers violated their terms of use.
- •Description of the main mobile platforms
- •Android sdk and jdk
- •Eclipse
- •Web Server
- •Php and json
- •The use case diagram
- •Figure 4 - Example of a use case diagram
- •3.2.2 Register.Java[11]
- •3.2.4 Succes.Java[11]
- •3.2.5 Call.Java[11]
- •3.2.6 JsonParser.Java[11]
- •Figure 9 - jsonParser.Java
- •3.5 User's Guide to the application's
- •4.2 Android Market
- •4.3.3 The costs of operation and maintenance of equipment
- •5.2 Analysis of dangerous and harmful factors
- •5.3 Production sanitation and health
- •5.6 Safety precautions when working with a computer
- •Figure 16 - location of fixtures
- •Conclusion
- •References [1] Android, the world's most popular mobile platform http://developer.Android.Com/about/index.Html
- •19.12.2007) Astana, Akorda, on May 15, 2007
- •[14] Php Cookbook: Solutions and Examples for php Programmers, Second Edition, David Sklar,August, 2006
3.2.6 JsonParser.Java[11]
This class is used for connection with application and php scripts. The application gives parameters and this class converts this to comfortable json format and opens http connection. It also sends information to the server and receives from the 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 parameters: String url is used for getting the address that will send this information, String method is used to know the method of connection Get or Post, List<NameValuePair> params is parameters to send.
Table 7 – variables of class JSONParser.java
Name |
Type |
description |
Is |
InputStream |
For saving InputStream |
jObj |
JSONObject |
For saving object of JSON |
Continue of Table 7 – variables of class JSONParser.java |
||
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 is drawn example class JSONParser.java
public class JSONParser {
static InputStream is = null;
static JSONObject jObj = null;
static String json = "";
public JSONParser() {
}
public JSONObject makeHttpRequest(String url, String method,
List<NameValuePair> params) {
try {
if(method == "POST"){
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"){
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;
}
}