Android下通过HttpClient执行 HTTP POST 请求的代码

枕上从妨一夜睡,灯前读尽十年诗。这篇文章主要讲述Android下通过HttpClient执行 HTTP POST 请求的代码相关的知识,希望能为你提供帮助。
【Android下通过HttpClient执行 HTTP POST 请求的代码】如下代码段是关于android下通过HttpClient执行 HTTP POST 请求的代码。
public void postData() {
HttpClient httpclient = new DefaultHttpClient();

try { List< NameValuePair> nameValuePairs = new ArrayList& lt; NameValuePair& gt; (2); nameValuePairs.add(new BasicNameValuePair("id", "12345")); nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!")); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = httpclient.execute(httppost); } catch (ClientProtocolException e) { } catch (IOException e) { }

}

    推荐阅读