//貌似必须要是异步的我把它放在AsyncTask里面执行一下就是代码例子
HttpResponse httpResponse = null;
try {
String urlString =
"http://10.10.1.203:3651/WebServicesForAndroid/AndoidHandler.ashx";
HttpPost
httpPost = new HttpPost(urlString);
List<NameValuePair> list = new
ArrayList<NameValuePair>();
list.add(new
BasicNameValuePair("Method", "addQZXS"));
list.add(new
BasicNameValuePair("Name",
nameEditText.getText()
.toString()));
list.add(new
BasicNameValuePair("Phone",
phoneEditText
.getText().toString()));
list.add(new
BasicNameValuePair("lb_id",
""));
list.add(new
BasicNameValuePair("Content",
contentEditText
.getText().toString()));
list.add(new
BasicNameValuePair("zb_id",
itID.toString()));
list.add(new
BasicNameValuePair("Image",
get_Add_InspectionTable_Image_String()));
httpPost.setEntity(new UrlEncodedFormEntity(list,
HTTP.UTF_8));
httpResponse = new
DefaultHttpClient().execute(httpPost);
if
(httpResponse.getStatusLine().getStatusCode() == 200) {
String result =
EntityUtils.toString(httpResponse
.getEntity());
Log.v("msg",
result);
Gson gson = new Gson();
java.lang.reflect.Type listType
= new TypeToken<LinkedList<HashMap<String, String>>>()
{
}.getType();
resultmessage = gson.fromJson(result,
listType);
}
} catch (Exception e)
{
e.printStackTrace();
}
//第一次接触POST传输,感觉应该能再改善