我需要在我的应用程序中通过 Post 方法将一些值传递给 URL。请帮忙
最佳答案
下面是一些将发出 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));
关于android - 使用 Android 进行 HTTP Post,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3912494/