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 ...
随机推荐
- mac osx 制作安装u盘
制作OS X El Capitan 原版安装U盘:sudo /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/Resources/creat ...
- ssh远程连接错误
在平时工作中,有时候需要SSH登陆到别的Linux主机上去,但有时候SSH登陆会被禁止,并弹出如下类似提示: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ...
- mysql 安装日志
善于使用 mysqld.exe --console 来得到提示
- CSS组件架构的设计思想
不管是设计思想,还是架构,都可以总结为一个词:AO模式.A表示Append,即“附加”的意思,O表示Overwrite,即“重写”的意思.所有的CSS组件都是沿用这种思想来设计的.这也是CSS的特性, ...
- Windows自带的驱动程序例子都在哪里?
MSDN官方说明:https://msdn.microsoft.com/windows/hardware/drivers/samples/index 各个操作系统驱动例子: Windows10 :h ...
- my first article
BLOG: http://codetask.org GIT: http://git.oschina.net/codetimer
- 关于Unity中Camera的Aspect
一直以来对Camera的Aspect和Game窗口的Aspect都是一知半解,某天从一本书中看到了对Camera的API讲解,但是总觉得对Aspect讲解的有问题.于是就认真的思考起了这个问题,还发现 ...
- 基于Linux 的VM TOOLS Install
VMware Tools Install 在VMware中为Linux系统安装VM-Tools的详解教程 如果大家打算在VMware虚拟机中安装Linux的话,那么在完成Linux的安装后,如果没 ...
- NHibernate系列文章十六:使用程序集管理NHibernate项目(附程序下载)
摘要 在实际的项目中,经常是将NHibernate的实体关系映射类做成独立的工程(assembly dll),只对外提供Session调用的接口.这个程序集作为数据访问层,可以被上面的多个工程(ASP ...
- 由tombstone文件解析jni代码过程
Android开发测试会经常遇到crash. (1)adb shell (2)cd /data/tombstones/ (3)adb pull /data/tombstones/tombston_00 ...