Gradle3.0自动化项目构建技术精讲+实战
作者:互联网
download:Gradle3.0自动化项目构建技术精讲+实战
Gradle已全面成熟的被用于各大公司的 Android,Java等工程构建中,也是大型互联网公司面试的必考点。本课程将通过多个企业级实战案例,让你完整掌握Gradle的全部核心知识以及高级用法,高效使用Gradle进行构建脚本的编写,解决构建过程中遇到的大部分难题,快速晋升高级工程师。
适合人群及技术储备要求
所有从事Java,Android相关的开发人员
技术储备要求:
至少有一个Android项目开发经验,有Groovy基础
对工程构建有一定的了解
package com.chengxinet.bobo.utils;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.telephony.TelephonyManager;
/**
- Created by Administrator on 2016/1/7.
*/
public class NetworkUtils {
public static boolean isNetworkAvailable(Context c) {
Context context = c.getApplicationContext();
// 获取手机一切衔接管理对象(包括对wi-fi,net等衔接的管理)
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivityManager == null) {
return false;
} else {
// 获取NetworkInfo对象
NetworkInfo[] networkInfo = connectivityManager.getAllNetworkInfo();
if (networkInfo != null && networkInfo.length > 0) {
for (NetworkInfo aNetworkInfo : networkInfo) {
// System.out.println(i + "===状态===" + networkInfo[i].getState());
// System.out.println(i + "===类型===" + networkInfo[i].getTypeName());
// 判别当前网络状态能否为衔接状态
if (aNetworkInfo.getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
}
}
return false;
}
/**- 判别WIFI能否翻开
- @param context
- @return
*/
public static boolean isWifiEnabled(Context context) {
ConnectivityManager mgrConn = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
TelephonyManager mgrTel = (TelephonyManager) context
.getSystemService(Context.TELEPHONY_SERVICE);
return ((mgrConn.getActiveNetworkInfo() != null && mgrConn
.getActiveNetworkInfo().getState() == NetworkInfo.State.CONNECTED) || mgrTel
.getNetworkType() == TelephonyManager.NETWORK_TYPE_UMTS);
}
/** - 判别能否是3G网络
- @param context
- @return
*/
public static boolean is3rd(Context context) {
ConnectivityManager cm = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkINfo = cm.getActiveNetworkInfo();
if (networkINfo != null
&& networkINfo.getType() == ConnectivityManager.TYPE_MOBILE) {
return true;
}
return false;
}
/** - 判别是wifi还是3g网络
- @param context
- @return
*/
public static boolean isWifi(Context context) {
ConnectivityManager cm = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkINfo = cm.getActiveNetworkInfo();
if (networkINfo != null
&& networkINfo.getType() == ConnectivityManager.TYPE_WIFI) {
return true;
}
return false;
}
}
标签:实战,networkInfo,return,Context,ConnectivityManager,精讲,context,NetworkInfo,Gradle3 来源: https://blog.51cto.com/u_15161311/2695736