use of android.net.ConnectivityManager in project weiciyuan by qii.
the class Utility method isWifi.
public static boolean isWifi(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = cm.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected()) {
if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
return true;
}
}
return false;
}
use of android.net.ConnectivityManager in project weiciyuan by qii.
the class AboutFragment method buildContent.
private String buildContent() {
String network = "";
ConnectivityManager cm = (ConnectivityManager) getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = cm.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnected()) {
if (networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
network = "Wifi";
} else if (networkInfo.getType() == ConnectivityManager.TYPE_MOBILE) {
int subType = networkInfo.getSubtype();
if (subType == TelephonyManager.NETWORK_TYPE_GPRS) {
network = "GPRS";
}
}
}
return "@四次元App #四次元App反馈# " + android.os.Build.MANUFACTURER + " " + android.os.Build.MODEL + ",Android " + android.os.Build.VERSION.RELEASE + "," + network + " version:" + buildVersionInfo();
}
use of android.net.ConnectivityManager in project android by cSploit.
the class Network method isWifiConnected.
public static boolean isWifiConnected(Context context) {
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
return info != null && info.isConnected() && info.isAvailable();
}
use of android.net.ConnectivityManager in project android by cSploit.
the class Network method isConnectivityAvailable.
public static boolean isConnectivityAvailable(Context context) {
ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = manager.getActiveNetworkInfo();
return info != null && info.isConnected();
}
use of android.net.ConnectivityManager in project GeekNews by codeestX.
the class SystemUtil method isMobileNetworkConnected.
/**
* 检查手机网络(4G/3G/2G)是否连接
*/
public static boolean isMobileNetworkConnected() {
ConnectivityManager connectivityManager = (ConnectivityManager) App.getInstance().getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mobileNetworkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
return mobileNetworkInfo != null;
}
Aggregations