HttpClient请求网络数据的Post请求
new Thread(){
public void run() {
try {
//获得输入框内容
String phonenum=et_phone_num.getText().toString().trim();
String password=et_password.getText().toString().trim();
String name=et_name.getText().toString().trim();
HttpClient client=new DefaultHttpClient();
HttpPost post=new HttpPost(urlPath);
//将汉字编码
String ss=URLEncoder.encode(name, "utf-8");
List<NameValuePair> parameters=new ArrayList<NameValuePair>();
parameters.add(new BasicNameValuePair("userName", ss));
parameters.add(new BasicNameValuePair("userPhone", phonenum));
parameters.add(new BasicNameValuePair("userPassword", password));
HttpEntity entity=new UrlEncodedFormEntity(parameters,"utf-8");
post.setEntity(entity);
HttpResponse response=client.execute(post);
StatusLine line=response.getStatusLine();
int code=line.getStatusCode();
if (code==200) {
HttpEntity entity2=response.getEntity();
String result=EntityUtils.toString(entity2,"utf-8");
Message message=new Message();
message.obj=result;
message.what=1;
handler.sendMessage(message);
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
};
}.start();
HttpClient请求网络数据的Post请求的更多相关文章
- HttpURLConnection请求网络数据的Post请求
//--------全局变量----------- //注册Url private String urlPath="http://101.200.142.201:8080/VideoP ...
- HttpURLConnection请求网络数据的GET请求
//清单文件中添加权限 <uses-permission android:name="android.permission.INTERNET"/> new Thread ...
- react-native 项目实战 -- 新闻客户端(4) -- 请求网络数据
1.Home.js /** * 首页 */ import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Te ...
- Android 手机卫士--构建服务端json、请求网络数据
本文地址:http://www.cnblogs.com/wuyudong/p/5900384.html,转载请注明源地址. 数据的传递 客户端:发送http请求 http://www.oxx.com/ ...
- Android - 使用Volley请求网络数据
Android - 使用Volley请求网络数据 Android L : Android Studio 14 个人使用volley的小记,简述使用方法,不涉及volley源码 准备工作 导入Volle ...
- HttpURLConnection请求网络数据
//使用线程 new Thread(){ public void run() { try { //先创建出了一 ...
- IOS开发中使用AFNetworking请求网络数据
1.把AFNetworking的文件拖放到项目中(注意不同的版本方法不一样,本历程基于版本2013): 2.使用#import "AFNetworking.h"命令把AFNetwo ...
- angularjs $http请求网络数据并展示
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- post NSURLConnection请求网络数据
#import "ViewController.h" @interface ViewController () @end @implementation ViewControlle ...
随机推荐
- Maven根据不同个环境打包, 获取不同的配置文件等等
http://www.cnblogs.com/tartis/p/5391079.html <project xmlns="http://maven.apache.org/POM/4.0 ...
- -include和sinclude 作用
-include和sinclude 如果有文件没有找到的话,make会生成一条警告信息,但不会马上出现致命错误.它 会继续载入其它的文件,一旦完成makefile的读取,make会再重试这些没有找 ...
- Java 开发必会的 Linux 命令
作为一个Java开发人员,有些常用的Linux命令必须掌握.即时平时开发过程中不使用Linux(Unix)或者mac系统,也需要熟练掌握Linux命令.因为很多服务器上都是Linux系统.所以,要和服 ...
- 25. Valid Palindrome
Valid Palindrome Given a string, determine if it is a palindrome, considering only alphanumeric char ...
- 46. Partition List
Partition List Given a linked list and a value x, partition it such that all nodes less than x come ...
- [VB.NET]调用系统的文件夹选择对话框
以下示例代码展示如何调用系统的文件夹选择对话框: Private Function SelectFolder(ByVal Describe As String, Optional ByVal Show ...
- ORACLE 10G 闪回建议
Flashback Tips The following tips and restrictions apply to using flashback features. Flashback Tips ...
- Could not load file using Ranorex runtime : General Questions
如果你将编译好的bin文件夹复制到另一个未安装Ranorex程序的电脑上运行遇到如下错误信息 Could not load file or assembly 'Ranorex.Core, Versio ...
- Android IOS WebRTC 音视频开发总结(七十)-- 移动端音视频技术优化的七个方向
最近直播很火,很多朋友对背后的技术比较感兴趣,所以今天我们整理一篇关于移动端视频优化的文章,这篇文章是我朋友在一个技术大会上分享过的,更多内容请关注我们的微信公众号:rtcblacker 视频直播为什 ...
- Egret 压缩与解压(jszip)
一 jszip是什么 二 为什么要用jszip 三 如果使用zip 一 jszip是什么 jszip 是一个 JavaScript 库,可直接在浏览器上创建 zip 压缩档. 二 为什么要用jszip ...