use of android.net.ConnectivityManager in project carat by amplab.
the class SamplingLibrary method getNetworkType.
/**
* Get the network type, for example Wifi, mobile, wimax, or none.
*
* @param context
* @return
*/
public static String getNetworkType(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (cm == null)
return TYPE_UNKNOWN;
NetworkInfo i = cm.getActiveNetworkInfo();
if (i == null)
return TYPE_UNKNOWN;
return i.getTypeName();
}
use of android.net.ConnectivityManager in project FileDownloader by lingochamp.
the class FileDownloadUtils method isNetworkOnWifiType.
public static boolean isNetworkOnWifiType() {
final ConnectivityManager manager = (ConnectivityManager) FileDownloadHelper.getAppContext().getSystemService(Context.CONNECTIVITY_SERVICE);
final NetworkInfo info = manager.getActiveNetworkInfo();
return info != null && info.getType() == ConnectivityManager.TYPE_WIFI;
}
use of android.net.ConnectivityManager in project KJFrameForAndroid by kymjs.
the class SystemTool method isWiFi.
/**
* 判断是否为wifi联网
*/
public static boolean isWiFi(Context cxt) {
ConnectivityManager cm = (ConnectivityManager) cxt.getSystemService(Context.CONNECTIVITY_SERVICE);
// wifi的状态:ConnectivityManager.TYPE_WIFI
// 3G的状态:ConnectivityManager.TYPE_MOBILE
State state = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState();
return State.CONNECTED == state;
}
use of android.net.ConnectivityManager in project KJFrameForAndroid by kymjs.
the class SystemTool method checkNet.
/**
* 判断网络是否连接
*/
public static boolean checkNet(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = cm.getActiveNetworkInfo();
// 网络是否连接
return info != null;
}
use of android.net.ConnectivityManager in project Lazy by l123456789jy.
the class MiscUtils method getAPN.
/**
*
* @param context 上下文
* @return apn
*/
public static String getAPN(Context context) {
String apn = "";
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = manager.getActiveNetworkInfo();
if (info != null) {
if (ConnectivityManager.TYPE_WIFI == info.getType()) {
apn = info.getTypeName();
if (apn == null) {
apn = "wifi";
}
} else {
apn = info.getExtraInfo().toLowerCase();
if (apn == null) {
apn = "mobile";
}
}
}
return apn;
}
Aggregations