小智 6
这是一些将发出HTTP POST请求的代码.取自http://androidadvice.blogspot.com/2010/10/httppost-request.html,其中还有一些额外的解释.
HttpClient httpclient = new DefaultHttpClient(httpParameters);
HttpPost httppost = new HttpPost(Constants.MAIN_URL);
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("u", eUsername));
nameValuePairs.add(new BasicNameValuePair("p", ePassword));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2866 次 |
| 最近记录: |