use of android.net.ConnectivityManager in project AnimeTaste by daimajia.
the class NetworkUtils method isWifiConnected.
/**
* make true current connect service is wifi
*
* @param mContext
* @return
*/
public static boolean isWifiConnected(Context mContext) {
ConnectivityManager connManager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if (mWifi.isConnected()) {
return true;
} else {
return false;
}
}
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 android-app by eoecn.
the class APNManager method getDefaultNetworkType.
public int getDefaultNetworkType() {
int networkType = -1;
ConnectivityManager connectivity = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity == null) {
} else {
// wifi network have priority
NetworkInfo wifiNetworkInfo = connectivity.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if (wifiNetworkInfo != null && wifiNetworkInfo.getState() == NetworkInfo.State.CONNECTED) {
return ConnectivityManager.TYPE_WIFI;
}
NetworkInfo[] info = connectivity.getAllNetworkInfo();
for (int i = 0; i < info.length; i++) {
if (info[i].getState() == NetworkInfo.State.CONNECTED) {
// use first available network
networkType = info[i].getType();
break;
}
}
}
return networkType;
}
use of android.net.ConnectivityManager in project android-app by eoecn.
the class NetWorkHelper method isWifiDataEnable.
/**
* 判断wifi 是否可用
* @param context
* @return
* @throws Exception
*/
public static boolean isWifiDataEnable(Context context) throws Exception {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
boolean isWifiDataEnable = false;
isWifiDataEnable = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnectedOrConnecting();
return isWifiDataEnable;
}
Aggregations