use of android.net.ConnectivityManager in project SimplifyReader by chentao0707.
the class NetUtils method isMobileConnected.
public static boolean isMobileConnected(Context context) {
if (context != null) {
ConnectivityManager mConnectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo mMobileNetworkInfo = mConnectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
if (mMobileNetworkInfo != null) {
return mMobileNetworkInfo.isAvailable();
}
}
return false;
}
use of android.net.ConnectivityManager in project SimplifyReader by chentao0707.
the class NetUtils method getAPNType.
public static NetType getAPNType(Context context) {
ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
if (networkInfo == null) {
return NetType.NONE;
}
int nType = networkInfo.getType();
if (nType == ConnectivityManager.TYPE_MOBILE) {
if (networkInfo.getExtraInfo().toLowerCase(Locale.getDefault()).equals("cmnet")) {
return NetType.CMNET;
} else {
return NetType.CMWAP;
}
} else if (nType == ConnectivityManager.TYPE_WIFI) {
return NetType.WIFI;
}
return NetType.NONE;
}
use of android.net.ConnectivityManager in project android-priority-jobqueue by path.
the class NetworkUtilImpl method isConnected.
@Override
public boolean isConnected(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
return netInfo != null && netInfo.isConnectedOrConnecting();
}
use of android.net.ConnectivityManager in project plaid by nickbutcher.
the class HomeActivity method onPause.
@Override
protected void onPause() {
dribbblePrefs.removeLoginStatusListener(filtersAdapter);
if (monitoringConnectivity) {
final ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
connectivityManager.unregisterNetworkCallback(connectivityCallback);
monitoringConnectivity = false;
}
super.onPause();
}
use of android.net.ConnectivityManager in project mobile-android by photo.
the class CommonUtils method isWiFiActive.
/**
* Check whether the device is connected to WiFi network and it is active
* connection
*
* @return true if device is connected to WiFi network and it is active,
* otherwise return false
*/
public static boolean isWiFiActive() {
boolean result = false;
try {
ConnectivityManager cm = (ConnectivityManager) CommonConfigurationUtils.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
if (netInfo != null && netInfo.getType() == ConnectivityManager.TYPE_WIFI && netInfo.isConnectedOrConnecting()) {
result = true;
}
} catch (Exception ex) {
error(TAG, "Error", ex);
}
return result;
}
Aggregations