- 浏览: 20672 次
文章分类
最新评论
//post
HttpClient client=new DefaultHttpClient();
HttpPost post=new HttpPost("路径");
post.setHeader("Content-Type","application/x-www-form-urlencoded");
List<NameValuePair> pairs=new ArrayList<NameValuePair>();
pairs.add(new BasicNameValuePair("device_uuid",uuid));
pairs.add(new BasicNameValuePair("app_version"),app_version);
try{
post.setEntity(new UrlEncodedFormEntity(pairs));
//UrlEncodedFormEntity,这里第二个参数可以加"utf-8"
}catch(UnsupportedEncodingException e){
e.printStackTrace();
}
try{
client.execute(post);
}catch(Exeption e){
}
----------------------------------------------------------------------
//get
DefaultHttpClient client=new DefaultHttpClient();
HttpGet get=new HttpGet(String url);//url参数,形如?x=1&y=2
HttpResponse response=client.execute(get);
int code=response.getStatusLine().getStatusCode();//返回码200 成功
if(code==200){
InputStream in=response.getEntity().getContent();//返回的数据
}
要添加权限: <uses-permission android:name="android.permission.INTERNET" />
HttpClient client=new DefaultHttpClient();
HttpPost post=new HttpPost("路径");
post.setHeader("Content-Type","application/x-www-form-urlencoded");
List<NameValuePair> pairs=new ArrayList<NameValuePair>();
pairs.add(new BasicNameValuePair("device_uuid",uuid));
pairs.add(new BasicNameValuePair("app_version"),app_version);
try{
post.setEntity(new UrlEncodedFormEntity(pairs));
//UrlEncodedFormEntity,这里第二个参数可以加"utf-8"
}catch(UnsupportedEncodingException e){
e.printStackTrace();
}
try{
client.execute(post);
}catch(Exeption e){
}
----------------------------------------------------------------------
//get
DefaultHttpClient client=new DefaultHttpClient();
HttpGet get=new HttpGet(String url);//url参数,形如?x=1&y=2
HttpResponse response=client.execute(get);
int code=response.getStatusLine().getStatusCode();//返回码200 成功
if(code==200){
InputStream in=response.getEntity().getContent();//返回的数据
}
要添加权限: <uses-permission android:name="android.permission.INTERNET" />
发表评论
-
android startActivityForResult
2012-12-25 09:02 531Bashboard.java Intent i = new I ... -
android 实现左右滑动指引效果
2012-12-18 17:29 647见附录源码 ViewPager 的使用 -
android listview 点击listview下面 显示更多
2012-12-18 15:05 1251见附件源码. 看一遍就懂了,很简单的例子. -
android listview 上拉刷新
2012-12-18 13:45 741具体源码见,附件下载。 这里列出关键性思路: 1.先定义一个 ... -
android listview
2012-12-17 17:32 0android:drawSelectorOnTop=" ... -
android 实用方法
2012-12-17 15:28 0URLUtil.isValidUrl(String blogU ... -
android 分隔线
2012-12-17 15:27 872android 分隔线 1.用View 配置文件 <V ... -
android textview
2012-12-17 11:25 618textview 标题style设置. <style ... -
android edittext 边框 源码实现
2012-12-17 10:34 1207android经典edittext选中样式是,黄色,不选中是灰 ... -
android 布局边框
2012-12-17 09:25 798<RelativeLayout androi ... -
android 返回键 事件
2012-12-17 08:58 765//startActivityForResult()情况的In ... -
android 文字描边
2012-12-14 17:17 1935文字描边 android:shadowColor=" ... -
android 渐变背景
2012-12-14 15:43 1255<?xml version="1.0" ... -
android button 自定义
2012-12-14 14:58 632wp_button.xml(\drawable目录下建个) ... -
android application
2012-12-14 14:03 572android 开发中共享全局 ... -
android windowSoftInputMode
2012-12-14 11:42 532android:windowSoftInputMode属性 & ... -
android 屏幕
2012-12-07 10:33 666术语和概念 Screen size(屏幕尺寸) 指手机实际的物 ... -
android 绑定 service
2012-11-29 10:39 1663(1) 一个Activity和一个Service绑定在一起,一 ... -
android 国际化 屏幕适配 样式和主题
2012-11-23 15:19 1264(1)国际化 values文件夹:如果没找到语言环境对应的默认 ... -
android 自定义 checkbox
2012-11-01 10:33 725<?xml version="1.0" ...
相关推荐
android基础 POST GET 读取后台语言(PHP JSP)的程序!
此demo演示android通过get和post请求方法同服务器交互,测试需要tomcat,具体参考 http://blog.csdn.net/youmingyu/article/details/52524538
android 后台 post和get 请求数据。定义接收数据编码
这个是关于android的OkHttp3框架的代码实例,里面包括POST和GET请求,请大家多多指教。
Android中Https请求get和post 博客地址:http://blog.csdn.net/lsf1025995457/article/details/51794377
android通过POST和GET向服务器发送数据.包括使用普通HTTP协议发送和使用android内置的HttpClient进行发送。
android get和post 获取json xml数据
android Http get_post get方法封装 post方法封装
android发送get,post请求工具类
Android端使用get post 方法提交数据到服务器demo 传智播客张泽华Android视频54-57代码 包括web和Android端 仅供学习
这个程序代码很好的实现了,通过get post 两种方式与服务器进行通讯的连接!需要了解android 网络传输的朋友可以下载看看!!
android getpost url 安卓中get post的实现源码 代码 倾吐工作室
简单的http post请求,http get请求实例,希望可以帮到你。
一个关于Android客户端请求服务器端代码,涉及到Get/Post请求和Android中android-async-http-master插件的使用。
andriod Volley的HTTP网络通信,包含get、post请求,获取String/JsonObject/JsonArray数据(android客户端+java服务器端)
框架主要包括:Get请求、Post请求、文件上传、文件下载。效果图及讲解见:https://blog.csdn.net/ahuyangdong/article/details/82760382。github源码:https://github.com/ahuyangdong/RetrofitFrame
分别演示了android中Http和HttpClient的Get和Post方法的使用,还有加载图片的演示
// <uses-permission android:name="android.permission.INTERNET" /> view sourceprint? 01 //2.需要编写一个服务器servlet代码 02 String userName = request.getParameter("userName"); 03 String password...
android 网络访问 get post 框架
网上已经有很多关于http的get与post的例子,不过,我还是将我的实现方式写了出来,主要的区别在于,我的调用函数,有几个优点: 1,做了一个工具类,集成到工程中比较方便; 2,可以直接调用,不需要new一个对象; 3...