// 这里写入子线程需要做的工作
String path = "http://192.168.10.251:8081/upload.jsp";
HttpPost httpRequest = new HttpPost(path);
/*
* NameValuePair实现请求参数的封装
*/
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("json", latitude + ","
+ longitude));
try {
/* 添加请求参数到请求对象 */
httpRequest.setEntity(new UrlEncodedFormEntity(params,
HTTP.UTF_8));
/* 发送请求并等待响应 */
HttpResponse httpResponse = new DefaultHttpClient()
.execute(httpRequest);
/* 若状态码为200 ok */
if (httpResponse.getStatusLine().getStatusCode() != 404) {
/* 读返回数据 */
String strResult = EntityUtils
.toString(httpResponse.getEntity());
Log.i(TAG, strResult);
}
} catch (Exception e) {
e.printStackTrace();
}
String path = "http://192.168.10.251:8081/upload.jsp";
HttpPost httpRequest = new HttpPost(path);
/*
* NameValuePair实现请求参数的封装
*/
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("json", latitude + ","
+ longitude));
try {
/* 添加请求参数到请求对象 */
httpRequest.setEntity(new UrlEncodedFormEntity(params,
HTTP.UTF_8));
/* 发送请求并等待响应 */
HttpResponse httpResponse = new DefaultHttpClient()
.execute(httpRequest);
/* 若状态码为200 ok */
if (httpResponse.getStatusLine().getStatusCode() != 404) {
/* 读返回数据 */
String strResult = EntityUtils
.toString(httpResponse.getEntity());
Log.i(TAG, strResult);
}
} catch (Exception e) {
e.printStackTrace();
}