android - 使用 Android 进行 HTTP Post

标签 android

我需要在我的应用程序中通过 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/

相关文章:

android - 倾听并回应 ANR?

android - 防止 Cordova Media 插件停止 native Android 应用程序音乐

android - 我如何将 ISO 时间转换为 android 中的 IST 和 GMT?

android - 如何获取设备上安装的所有共享应用程序?

android - 如何存储卸载后保留的数据

java - 如何在Android App中获取两个日期之间的时差?

android - 主线程使用

android - Gradle 构建一组 Android 项目(包括库)

java - 如何编写一个以 fragment 类作为参数的方法,该方法将允许我创建该 fragment 的新实例?

android - 父类(super class)android生命周期