Xutils请求服务器json数据与下载文件
来源:互联网 发布:竞猜网站源码 编辑:程序博客网 时间:2024/05/16 17:29
String code_url = "https://ic.snssdk.com/user/mobile/send_code/v2/";
HttpUtils httpUtils = new HttpUtils();
//网址 RequestParams params = new RequestParams(); params.addBodyParameter("type", "1");// 必填 params.addBodyParameter("mobile",shoujihao );// 必填
httpUtils.send(HttpMethod.POST, code_url, params, new RequestCallBack<String>() { @Override public void onStart() { // TODO Auto-generated method stub super.onStart(); Log.i("TAG", "请求开始"); } @Override public void onFailure(HttpException arg0, String arg1) { Log.i("TAG", "发送验证码请求失败: " + arg1); Toast.makeText(PhoneZhuCe.this, "发送验证码请求失败: "+ arg1, 0).show(); } @Override public void onSuccess(ResponseInfo<String> arg0) { Log.i("TAG", "发送验证码请求成功: " + arg0.result); String s=arg0.result;
Gson gson=new Gson(); Loginphone fromJson = gson.fromJson(s, Loginphone.class); String message = fromJson.getMessage(); if(message.equals("success")){ Intent intent = new Intent(PhoneZhuCe.this, PhoneZhuCe2.class); startActivity(intent); }else{ Toast.makeText(PhoneZhuCe.this, fromJson.getData().getDescription(), 0) .show(); } } });
下载数据:
String path = Environment.getExternalStorageDirectory().getPath(); String target=path+"/image/"+num+".png";//下载文件保存的路径 HttpUtils http=new HttpUtils();
//url路径 HttpHandler handler=http.download(url, target, true, true,new RequestCallBack<File>() { @Override public void onSuccess(ResponseInfo<File> arg0) { // TODO Auto-generated method stub } @Override public void onFailure(HttpException arg0, String arg1) { // TODO Auto-generated method stub } });
0 0
- Xutils请求服务器json数据与下载文件
- xUtils怎么post请求上传json数据
- Xutils从服务器获取json数据
- Android---Volley请求 Json解析 xUtils数据存储
- XUtils请求数据
- Xutils请求网络数据
- xUtils解析json数据
- 从服务器用xutils获取json,并用gson解析,包括用xutils下载文件
- XML 数据请求与JSON 数据请求
- XUtils下载文件
- xutils 关于下载文件。
- Xutils下载文件
- xutils向服务器发送json
- Android与与服务器交换数据、上传、下载、读取文件
- xUtils进行网络请求数据
- IE11下请求JSON下载文件
- 从服务器上请求json数据,并解析json数据
- HTTP请求与数据下载
- NSString 截取字符串
- Perl的Net::SSH::Perl模块实现远程登陆ssh
- Android手机 Fildder真机抓包
- Android第三方登录详解1
- Android第三方登录详解2
- Xutils请求服务器json数据与下载文件
- android简单的夜间模式
- Unique Game Conjecture
- Android判断网络状态
- Android中的通知—Notification
- android小功能:checkbox使用自己的背景点击切换背景
- android手机推送消息 (百度云推送)
- Android APP分享(第三方友盟)
- horizontalscrollview+textview简单版