1、源码简介:
主要有以下模块:
(1) 自动注入框架(只需要继承框架内的application既可)
(2) 图片加载框架(多重缓存,自动回收,最大限度保证内存的安全性)
(3) 网络请求模块(继承了基本上现在所有的http请求)
(4) eventbus(集成一个开源的框架)
(5) 验证框架(集成开源框架)
(6) json解析(支持解析成集合或者对象)
(7) 数据库(不知道是哪位写的 忘记了)
(8) 多线程断点下载(自动判断是否支持多线程,判断是否是重定向)
(9) 自动更新模块
(10) 一系列工具类
2、代码片段
<span style="font-size:18px;">
public class Handler_Network {
/**
* 检测手机是否开启GPRS网络,需要调用ConnectivityManager,TelephonyManager 服务.
*
* @param context
* @return boolean
*/
public static boolean checkGprsNetwork(Context context) {
boolean has = false;
ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
TelephonyManager mTelephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
NetworkInfo info = connectivity.getActiveNetworkInfo();
int netType = info.getType();
int netSubtype = info.getSubtype();
if (netType == ConnectivityManager.TYPE_MOBILE && netSubtype == TelephonyManager.NETWORK_TYPE_UMTS && !mTelephony.isNetworkRoaming()) {
has = info.isConnected();
}
return has;
}
/**
* 检测手机是否开启WIFI网络,需要调用ConnectivityManager服务.
*
* @param context
* @return boolean
*/
public static boolean checkWifiNetwork(Context context) {
boolean has = false;
ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = connectivity.getActiveNetworkInfo();
int netType = info.getType();
int netSubtype = info.getSubtype();
if (netType == ConnectivityManager.TYPE_WIFI) {
has = info.isConnected();
}
return has;
}
/**
* 检测当前手机是否联网
*
* @param context
* @return boolean
*/
public static boolean isNetworkAvailable(Context context) {
ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity == null) {
return false;
} else {
NetworkInfo[] info = connectivity.getAllNetworkInfo();
if (info != null) {
for (int i = 0; i < info.length; i++) {
if (info[i].getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
}
}
return false;
}
/**
* 手机是否处在漫游
*
* @param mCm
* @return boolean
*/
public boolean isNetworkRoaming(Context mCm) {
ConnectivityManager connectivity = (ConnectivityManager) mCm.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity == null) {
return false;
}
NetworkInfo info = connectivity.getActiveNetworkInfo();
boolean isMobile = (info != null && info.getType() == ConnectivityManager.TYPE_MOBILE);
TelephonyManager mTm = (TelephonyManager) mCm.getSystemService(Context.TELEPHONY_SERVICE);
boolean isRoaming = isMobile && mTm.isNetworkRoaming();
return isRoaming;
}
}</span>
3、下载
http://pan.baidu.com/s/1i3oqaR7
From: http://www.devstore.cn/code/info/74.html