- 浏览: 3506699 次
- 性别:
- 来自: 杭州
文章分类
- 全部博客 (1491)
- Hibernate (28)
- spring (37)
- struts2 (19)
- jsp (12)
- servlet (2)
- mysql (24)
- tomcat (3)
- weblogic (1)
- ajax (36)
- jquery (47)
- html (43)
- JS (32)
- ibatis (0)
- DWR (3)
- EXTJS (43)
- Linux (15)
- Maven (3)
- python (8)
- 其他 (8)
- JAVASE (6)
- java javase string (0)
- JAVA 语法 (3)
- juddiv3 (15)
- Mule (1)
- jquery easyui (2)
- mule esb (1)
- java (644)
- log4j (4)
- weka (12)
- android (257)
- web services (4)
- PHP (1)
- 算法 (18)
- 数据结构 算法 (7)
- 数据挖掘 (4)
- 期刊 (6)
- 面试 (5)
- C++ (1)
- 论文 (10)
- 工作 (1)
- 数据结构 (6)
- JAVA配置 (1)
- JAVA垃圾回收 (2)
- SVM (13)
- web st (1)
- jvm (7)
- weka libsvm (1)
- weka屈伟 (1)
- job (2)
- 排序 算法 面试 (3)
- spss (2)
- 搜索引擎 (6)
- java 爬虫 (6)
- 分布式 (1)
- data ming (1)
- eclipse (6)
- 正则表达式 (1)
- 分词器 (2)
- 张孝祥 (1)
- solr (3)
- nutch (1)
- 爬虫 (4)
- lucene (3)
- 狗日的腾讯 (1)
- 我的收藏网址 (13)
- 网络 (1)
- java 数据结构 (22)
- ACM (7)
- jboss (0)
- 大纸 (10)
- maven2 (0)
- elipse (0)
- SVN使用 (2)
- office (1)
- .net (14)
- extjs4 (2)
- zhaopin (0)
- C (2)
- spring mvc (5)
- JPA (9)
- iphone (3)
- css (3)
- 前端框架 (2)
- jui (1)
- dwz (1)
- joomla (1)
- im (1)
- web (2)
- 1 (0)
- 移动UI (1)
- java (1)
- jsoup (1)
- 管理模板 (2)
- javajava (1)
- kali (7)
- 单片机 (1)
- 嵌入式 (1)
- mybatis (2)
- layui (7)
- asp (12)
- asp.net (1)
- sql (1)
- c# (4)
- andorid (1)
- 地价 (1)
- yihuo (1)
- oracle (1)
最新评论
-
endual:
https://blog.csdn.net/chenxbxh2 ...
IE6 bug -
ice86rain:
你好,ES跑起来了吗?我的在tomcat启动时卡在这里Hibe ...
ES架构技术介绍 -
TopLongMan:
...
java public ,protect,friendly,private的方法权限(转) -
贝塔ZQ:
java实现操作word中的表格内容,用插件实现的话,可以试试 ...
java 读取 doc poi读取word中的表格(转) -
ysj570440569:
Maven多模块spring + springMVC + JP ...
Spring+SpringMVC+JPA
项目中客户端与服务器端采用http请求进行交互,在这里我把http请求的工具类贴出来。
该工具类采用的是HttpClients框架,HTTP保存方式有两种选择 :一种:整个应用 只创建 一个HttpClient对象,然后保存在整个程序中去。此情况无法创建多线程中应用。
另一种:随时创建HttpClient对象。系统自动保存Session就行。此情况可能对系统资源消耗利害
用完之后请随时销毁HttpClient,避免系统中存在很多HttpClient对象。在这里我采用的是第二种。
包含两个java文件,第一个是主要的请求工具类文件,第二个主要是保存请求的session,下面见代码:
[cpp] view plaincopy
- package com.hlj.padtwo.util.util_public.httputil;
- import java.io.File;
- import java.io.IOException;
- import java.io.InputStream;
- import java.net.URLEncoder;
- import java.nio.charset.Charset;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.List;
- import java.util.Map;
- import javax.net.ssl.SSLHandshakeException;
- import org.apache.http.Header;
- import org.apache.http.HttpEntityEnclosingRequest;
- import org.apache.http.HttpHost;
- import org.apache.http.HttpRequest;
- import org.apache.http.HttpResponse;
- import org.apache.http.NameValuePair;
- import org.apache.http.NoHttpResponseException;
- import org.apache.http.client.ClientProtocolException;
- import org.apache.http.client.CookieStore;
- import org.apache.http.client.HttpRequestRetryHandler;
- import org.apache.http.client.entity.UrlEncodedFormEntity;
- import org.apache.http.client.methods.HttpGet;
- import org.apache.http.client.methods.HttpPost;
- import org.apache.http.client.params.HttpClientParams;
- import org.apache.http.conn.params.ConnRouteParams;
- import org.apache.http.entity.mime.HttpMultipartMode;
- import org.apache.http.entity.mime.MultipartEntity;
- import org.apache.http.entity.mime.content.ContentBody;
- import org.apache.http.entity.mime.content.FileBody;
- import org.apache.http.entity.mime.content.StringBody;
- import org.apache.http.impl.client.DefaultHttpClient;
- import org.apache.http.params.BasicHttpParams;
- import org.apache.http.params.HttpConnectionParams;
- import org.apache.http.params.HttpParams;
- import org.apache.http.protocol.ExecutionContext;
- import org.apache.http.protocol.HTTP;
- import org.apache.http.protocol.HttpContext;
- import org.apache.http.util.EntityUtils;
- import android.app.Activity;
- import android.content.Context;
- import android.widget.Toast;
- import com.hlj.padtwo.util.application.MyApplication;
- /***
- * Http通信中的POST和GET请求方式的不同。GET把参数放在URL字符串后面,传递给服务器。
- * 而POST方法的参数是放在Http请求中,主要用于手机对Http访问提供公共的访问类对象。
- * @author hlj
- * @date
- * @versionn 1.0
- **/
- public class HttpClients {
- /** 执行downfile后,得到下载文件的大小 */
- private long contentLength;
- /** 返回连接失败信息 **/
- private String strResult = "服务器无法连接,请检查网络";
- /** http 请求头参数 **/
- private HttpParams httpParams;
- /** httpClient 对象 **/
- private DefaultHttpClient httpClient;
- /** 得到上下文 **/
- private Context context;
- private Activity activity = null;
- public HttpClients(Activity act) {
- this.context = act.getBaseContext();
- this.activity = act;
- getHttpClient();
- }
- /**
- * 提供GET形式的访问网络请求 doGet 参数示例: Map params=new HashMap();
- * params.put("usename","helijun"); params.put("password","123456");
- * httpClient.doGet(url,params);
- *
- * @param url
- * 请求地址
- * @param params
- * 请求参数
- * @return 返回 String jsonResult;
- *
- * **/
- @SuppressWarnings("unchecked")
- public String doGet(String url, Map params) {
- /** 建立HTTPGet对象 **/
- String paramStr = "";
- if (params == null)
- params = new HashMap();
- /** 迭代请求参数集合 **/
- Iterator iter = params.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry) iter.next();
- Object key = entry.getKey();
- String val = nullToString(entry.getValue());
- paramStr += paramStr = "&" + key + "=" + URLEncoder.encode(val);
- }
- if (!paramStr.equals("")) {
- paramStr = paramStr.replaceFirst("&", "?");
- url += paramStr;
- }
- return doGet(url);
- }
- /**
- * 提供GET形式的访问网络请求 doGet 参数示例: Map params=new HashMap();
- * params.put("usename","gongshuanglin"); params.put("password","123456");
- * httpClient.doGet(url,params);
- *
- * @param url
- * 请求地址
- * @param params
- * 请求参数
- * @return 返回 String jsonResult;
- *
- */
- public String doGet(String url, List<NameValuePair> params) {
- /** 建立HTTPGet对象 **/
- String paramStr = "";
- if (params == null)
- params = new ArrayList<NameValuePair>();
- /** 迭代请求参数集合 **/
- for (NameValuePair obj : params) {
- paramStr += paramStr = "&" + obj.getName() + "="
- + URLEncoder.encode(obj.getValue());
- }
- if (!paramStr.equals("")) {
- paramStr = paramStr.replaceFirst("&", "?");
- url += paramStr;
- }
- return doGet(url);
- }
- /**
- * 提供GET形式的访问网络请求 doGet 参数示例:
- *
- * @param url
- * 请求地址
- * @return 返回 String jsonResult;
- *
- */
- public String doGet(String url) {
- /** 创建HttpGet对象 **/
- HttpGet httpRequest = new HttpGet(url);
- httpRequest.setHeaders(this.getHeader());
- try {
- /** 保持会话Session **/
- /** 设置Cookie **/
- MyHttpCookies li = new MyHttpCookies(context);
- CookieStore cs = li.getuCookie();
- /** 第一次请求App保存的Cookie为空,所以什么也不做,只有当APP的Cookie不为空的时。把请请求的Cooke放进去 **/
- if (cs != null) {
- httpClient.setCookieStore(li.getuCookie());
- }
- /** 保持会话Session end **/
- /* 发送请求并等待响应 */
- HttpResponse httpResponse = httpClient.execute(httpRequest);
- /* 若状态码为200 ok */
- if (httpResponse.getStatusLine().getStatusCode() == 200) {
- /* 读返回数据 */
- strResult = EntityUtils.toString(httpResponse.getEntity());
- /** 执行成功之后得到 **/
- /** 成功之后把返回成功的Cookis保存APP中 **/
- // 请求成功之后,每次都设置Cookis。保证每次请求都是最新的Cookis
- li.setuCookie(httpClient.getCookieStore());
- } else {
- strResult = "Error Response: "
- + httpResponse.getStatusLine().toString();
- }
- } catch (ClientProtocolException e) {
- strResult = nullToString(e.getMessage());
- e.printStackTrace();
- } catch (IOException e) {
- strResult = nullToString(e.getMessage());
- e.printStackTrace();
- } catch (Exception e) {
- strResult = nullToString(e.getMessage());
- e.printStackTrace();
- } finally {
- httpRequest.abort();
- this.shutDownClient();
- }
- return strResult;
- }
- /**
- * 提供Post形式的访问网络请求 Post 参数示例: doPost 参数示例 List<NameValuePair> paramlist =
- * new ArrayList<NameValuePair>(); paramlist(new BasicNameValuePair("email",
- * "xxx@123.com")); paramlist(new BasicNameValuePair("address", "123abc"));
- * httpClient.doPost(url,paramlist);
- *
- * @param url
- * 请求地址
- * @param params
- * 请求参数
- * @return 返回 String jsonResult;
- * **/
- public String doPost(String url, List<NameValuePair> params) {
- /* 建立HTTPPost对象 */
- HttpPost httpRequest = new HttpPost(url);
- // 设置请求Header信息、
- httpRequest.setHeaders(this.getHeader());
- try {
- /** 添加请求参数到请求对象 */
- // boolean upFileFlag = false;// 是否有文件上传
- // MultipartEntity mpEntity = new MultipartEntity(
- // HttpMultipartMode.BROWSER_COMPATIBLE);
- // for (NameValuePair param : params) {
- // ContentBody contentBody = null;
- // File file = new File(param.getValue());
- // if (file.isFile()) {
- // contentBody = new FileBody(file);
- // upFileFlag = true;
- // } else {
- // contentBody = new StringBody(param.getValue(), Charset
- // .forName(HTTP.UTF_8));
- // }
- // mpEntity.addPart(param.getName(), contentBody);
- // }
- //
- // if (upFileFlag == true) {// 文件 上传
- // httpRequest.setEntity(mpEntity);
- // } else {
- /** 添加请求参数到请求对象 */
- httpRequest.setEntity(new UrlEncodedFormEntity(params,
- HTTP.UTF_8));
- // }
- /** 保持会话Session **/
- /** 设置Cookie **/
- MyHttpCookies li = new MyHttpCookies(context);
- CookieStore cs = li.getuCookie();
- /** 第一次请求App保存的Cookie为空,所以什么也不做,只有当APP的Cookie不为空的时。把请请求的Cooke放进去 **/
- if (cs != null) {
- httpClient.setCookieStore(li.getuCookie());
- }
- /** 保持会话Session end **/
- /** 发送请求并等待响应 */
- HttpResponse httpResponse = httpClient.execute(httpRequest);
- /** 若状态码为200 ok */
- if (httpResponse.getStatusLine().getStatusCode() == 200) {
- /* 读返回数据 */
- strResult = EntityUtils.toString(httpResponse.getEntity());
- /** 执行成功之后得到 **/
- /** 成功之后把返回成功的Cookis保存APP中 **/
- // 请求成功之后,每次都设置Cookis。保证每次请求都是最新的Cookis
- li.setuCookie(httpClient.getCookieStore());
- /** 设置Cookie end **/
- } else {
- strResult = "Error Response: "
- + httpResponse.getStatusLine().toString();
- }
- } catch (ClientProtocolException e) {
- strResult = "";
- // strResult = e.getMessage().toString();
- e.printStackTrace();
- } catch (IOException e) {
- strResult = "";
- // strResult = e.getMessage().toString();
- e.printStackTrace();
- } catch (Exception e) {
- strResult = "";
- // strResult = e.getMessage().toString();
- e.printStackTrace();
- } finally {
- httpRequest.abort();
- this.shutDownClient();
- }
- return strResult;
- }
- /** 得到 apache http HttpClient对象 **/
- public DefaultHttpClient getHttpClient() {
- /** 创建 HttpParams 以用来设置 HTTP 参数 **/
- httpParams = new BasicHttpParams();
- /** 设置连接超时和 Socket 超时,以及 Socket 缓存大小 **/
- HttpConnectionParams.setConnectionTimeout(httpParams, 20 * 1000);
- HttpConnectionParams.setSoTimeout(httpParams, 20 * 1000);
- HttpConnectionParams.setSocketBufferSize(httpParams, 8192);
- HttpClientParams.setRedirecting(httpParams, true);
- /**
- * 创建一个 HttpClient 实例 //增加自动选择网络,自适应cmwap、CMNET、wifi或3G
- */
- MyHttpCookies li = new MyHttpCookies(context);
- String proxyStr = li.getHttpProxyStr();
- if (proxyStr != null && proxyStr.trim().length() > 0) {
- HttpHost proxy = new HttpHost(proxyStr, 80);
- httpClient.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY,
- proxy);
- }
- /** 注意 HttpClient httpClient = new HttpClient(); 是Commons HttpClient **/
- httpClient = new DefaultHttpClient(httpParams);
- httpClient.setHttpRequestRetryHandler(requestRetryHandler);
- return httpClient;
- }
- /** 得到设备信息、系统版本、驱动类型 **/
- private Header[] getHeader() {
- /** 请求头信息 end **/
- MyHttpCookies li = new MyHttpCookies(context);
- return li.getHttpHeader();
- }
- /** 销毁HTTPCLient **/
- public void shutDownClient() {
- httpClient.getConnectionManager().shutdown();
- }
- // /**
- // * 提供GET形式的访问网络请求 doGet 参数示例:
- // *
- // * @param url
- // * 请求地址
- // * @return 返回 String jsonResult;
- // *
- // */
- // public InputStream doDownFile(String url) {
- // /** 创建HttpGet对象 **/
- // HttpGet httpRequest = new HttpGet(url);
- // httpRequest.setHeaders(this.getHeader());
- // try {
- // /** 保持会话Session **/
- // /** 设置Cookie **/
- // MyHttpCookies li = new MyHttpCookies(context);
- // CookieStore cs = li.getuCookie();
- // /** 第一次请求App保存的Cookie为空,所以什么也不做,只有当APP的Cookie不为空的时。把请请求的Cooke放进去 **/
- // if (cs != null) {
- // httpClient.setCookieStore(li.getuCookie());
- // }
- // /** 保持会话Session end **/
- // /* 发送请求并等待响应 */
- // HttpResponse httpResponse = httpClient.execute(httpRequest);
- // /* 若状态码为200 ok */
- // if (httpResponse.getStatusLine().getStatusCode() == 200) {
- // /** 执行成功之后得到 **/
- // /** 成功之后把返回成功的Cookis保存APP中 **/
- // // 请求成功之后,每次都设置Cookis。保证每次请求都是最新的Cookis
- // li.setuCookie(httpClient.getCookieStore());
- // this.contentLength = httpResponse.getEntity()
- // .getContentLength();
- // /* 读返回数据 */
- // return httpResponse.getEntity().getContent();
- // } else {
- // strResult = "Error Response: "
- // + httpResponse.getStatusLine().toString();
- // }
- // } catch (ClientProtocolException e) {
- // strResult = e.getMessage().toString();
- // e.printStackTrace();
- // } catch (IOException e) {
- // strResult = e.getMessage().toString();
- // e.printStackTrace();
- // } catch (Exception e) {
- // strResult = e.getMessage().toString();
- // e.printStackTrace();
- // } finally {
- // // httpRequest.abort();
- // // this.shutDownClient();
- // }
- // this.contentLength = 0;
- // return null;
- // }
- /**
- * 异常自动恢复处理, 使用HttpRequestRetryHandler接口实现请求的异常恢复
- */
- private static HttpRequestRetryHandler requestRetryHandler = new HttpRequestRetryHandler() {
- // 自定义的恢复策略
- public boolean retryRequest(IOException exception, int executionCount,
- HttpContext context) {
- // 设置恢复策略,在发生异常时候将自动重试N次
- if (executionCount >= 3) {
- // 如果超过最大重试次数,那么就不要继续了
- return false;
- }
- if (exception instanceof NoHttpResponseException) {
- // 如果服务器丢掉了连接,那么就重试
- return true;
- }
- if (exception instanceof SSLHandshakeException) {
- // 不要重试SSL握手异常
- return false;
- }
- HttpRequest request = (HttpRequest) context
- .getAttribute(ExecutionContext.HTTP_REQUEST);
- boolean idempotent = (request instanceof HttpEntityEnclosingRequest);
- if (!idempotent) {
- // 如果请求被认为是幂等的,那么就重试
- return true;
- }
- return false;
- }
- };
- public long getContentLength() {
- return contentLength;
- }
- /**
- * 假如obj对象 是null返回""
- * @param obj
- * @return
- */
- public static String nullToString(Object obj){
- if(obj==null){
- return "";
- }
- return obj.toString();
- }
- }
[cpp] view plaincopy
- package com.hlj.padtwo.util.util_public.httputil;
- import org.apache.http.Header;
- import org.apache.http.client.CookieStore;
- import org.apache.http.message.BasicHeader;
- import android.content.Context;
- import android.database.Cursor;
- import android.net.Uri;
- import android.net.wifi.WifiManager;
- /**
- * http请求的缓存和一些公用的参数
- * @author helijun
- *
- */
- public class MyHttpCookies {
- /** 每页数据显示最大数 */
- private static int pageSize = 10;
- /** 当前会话后的cokie信息 */
- private static CookieStore uCookie = null;
- /** 公用的HTTP提示头信息 */
- private static Header[] httpHeader;
- /** HTTP连接的网络节点 */
- private static String httpProxyStr;
- /**http请求的公用url部分**/
- public static String baseurl = "http://192.168.50.56:5056/River";
- /**上下文对象**/
- Context context;
- public MyHttpCookies(Context context){
- this.context = context;
- /** y设置请求头 **/
- /** y设置请求头 **/
- Header[] header = {
- new BasicHeader("PagingRows", String.valueOf(pageSize)) };
- httpHeader = header;
- }
- /**
- * 增加自动选择网络,自适应cmwap、CMNET、wifi或3G
- */
- @SuppressWarnings("static-access")
- public void initHTTPProxy() {
- WifiManager wifiManager = (WifiManager) (context.getSystemService(context.WIFI_SERVICE));
- if (!wifiManager.isWifiEnabled()) {
- Uri uri = Uri.parse("content://telephony/carriers/preferapn"); // 获取当前正在使用的APN接入点
- Cursor mCursor =context. getContentResolver().query(uri, null, null, null,
- null);
- if (mCursor != null) {
- mCursor.moveToNext(); // 游标移至第一条记录,当然也只有一条
- httpProxyStr = mCursor.getString(mCursor
- .getColumnIndex("proxy"));
- }
- } else {
- httpProxyStr = null;
- }
- }
- public int getPageSize() {
- return pageSize;
- }
- public void setPageSize(int pageSize) {
- this.pageSize = pageSize;
- }
- public CookieStore getuCookie() {
- return uCookie;
- }
- public void setuCookie(CookieStore uCookie) {
- this.uCookie = uCookie;
- }
- public Header[] getHttpHeader() {
- return httpHeader;
- }
- public String getHttpProxyStr() {
- return httpProxyStr;
- }
- }
发表评论
-
android离线
2019-11-04 21:25 261https://www.jianshu.com/p/fdfc4 ... -
android 异步更新
2015-07-11 22:42 1465http://www.apkbus.com/forum.php ... -
仿微米
2015-06-26 10:22 0http://www.javaapk.com/source/4 ... -
仿微信
2015-06-26 10:21 1873http://www.javaapk.com/source/1 ... -
网易客户端
2015-06-26 10:20 1562http://www.javaapk.com/source/4 ... -
仿朋友圈
2015-06-26 10:18 1665http://www.javaapk.com/source/8 ... -
仿朋友圈
2015-06-26 10:13 1779http://www.eoeandroid.com/threa ... -
全国ABC查询
2015-06-26 10:07 1272IM 功能 环信云 信息统计 Umeng 分享Umeng 更新 ... -
android 判断网络
2015-06-25 16:00 1220http://www.cnblogs.com/renqingp ... -
android 多彩表格
2015-05-31 16:06 1432http://blog.csdn.net/conowen/ar ... -
android socket
2015-05-31 16:01 1593http://blog.csdn.net/conowen/ar ... -
微信播放语音3
2015-02-25 12:00 1392http://download.csdn.net/detail ... -
微信语音播放2
2015-02-25 11:57 1296http://download.csdn.net/detail ... -
微信语音播放
2015-02-25 11:56 1643http://www.apkbus.com/android-1 ... -
超强的资料整合
2015-01-05 11:04 1196http://zz563143188.iteye.com/bl ... -
最强开发资源平台大合集
2015-01-04 14:50 1851程序员代码应用开发平 ... -
Android-Universal-Image-Loader 图片异步加载类库的使用(超详细配置)
2014-09-04 15:45 1335http://blog.csdn.net/vipzjyno1/ ... -
android应用推广
2014-09-03 23:25 1280应用推广不必愁,有米 ... -
android 图片异步加载
2014-09-03 16:47 1096http://www.csdn.net/article/201 ... -
android hander的使用
2014-09-02 23:46 1322http://www.cnblogs.com/xiaoran1 ...
相关推荐
HttpClient工具类,简单轻松的实现get,post,put和delete请求
android发送get,post请求工具类
自己封装的一个retrofit2.0 okHttp3 rxjava的网络请求工具类,拿过去直接可以使用
Android 动态权限工具类,使用简单方便,动态权限工具类动态权限工具类动态权限工具类动态权限工具类动态权限工具类动态权限工具类
TimeTask是一个轻量简洁的定时任务队列框架,专注处理多组任务分发工作 TimeTask内部的实现时基于AlarmManager 广播,在任务与系统api中间做了较好的封装
Android常用工具类,包含大部分Android常用的工具类,包括文件操作、图片操作、动态权限请求等
基于Android Volley的网络请求工具
JavaLite HTTP是一个用于发出HTTP请求和返回响应的小型库。 它没有除JDK之外的依赖项。
整理一些常用的安卓工具类,包含有AES加密,MD5加密,OKHTTP3,VOLLEY,XUTILS网络请求工具,Glide图片加载,沉浸式状态栏,自定义下来刷新/上拉加载更多,webview,缓存工具类,以及网络判断/用户信息判断/日期等工具类....
开源的异步http连接工具类源码. 示例代码: public class TwitterRestClient { private static final String BASE_URL = "http://api.twitter.com/1/"; private static AsyncHttpClient client = new ...
权限动态申请,可以动态处理,请求相关权限。注解模式
此代码为网络请求的工具类 包含原生的HttpClient 、HttpUrlConnection以及Xutils 和Volley框架的网络请求。
android请求webservice,以前没有找到封装的工具类,这里是对ksoap2-android-assemble的封装,可通过一行代码实现网络请求并获取数据,里面有大量的注释,可作为学习
请求参数通过RSA加密
MD5、RSA、Base64Utils、DialogUtil、ZXingUtils、GlideUtil、、、工具类 自己总结了一些必备的工具类,可直接放入工程,简单调用 对OkHttp进行了封装,简单调用,便于操作 进行了post、get、文件上传等进行封装
提供一个Android封装的http请求实用工具类,在做ANDROID网络开发中这个经常要用到,大家可以参考下面的工具类修改成自己的工具
喜欢的使用即可
自己总结的 封装了一些资源,网络请求是按照rxjava来封装的,不是很全面.其他的常用工具类及一些基础的视图组件封装。要使用,直接引用其工程就可以。是AS项目libary.
Android网络请求框架包含okhttp、volley、httpclient、xutils等jar包
设备信息获取工具类,获得设备型号、设备生产厂商、屏幕尺寸、GPS状态、wifi状态等。 DialogUtil.java 弹窗工具类,ProgressDialog,AlertDialog,Toast弹出封装。 ...