public class NetWorkUtil {
/**
* 检查是否有网络,没有则弹出选择框
* @param context
* @return
*/
public static boolean checkNewWork(final Context context){
boolean connect = false;
ConnectivityManager connectivity = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity != null) {
NetworkInfo[] info = connectivity.getAllNetworkInfo();
if (info != null)
for (int i = 0; i < info.length; i++) {
if (info[i].getState() == NetworkInfo.State.CONNECTED) {
connect = true;
}
}
}
return connect;
}
public static boolean checkWifiNetWork(final Context context){
boolean isWifi = false;
WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
if(wifi.isWifiEnabled()){
isWifi = true;
}
return isWifi;
}
}