use of android.net.ConnectivityManager in project Signal-Android by WhisperSystems.
the class OutgoingLegacyMmsConnection method isConnectionPossible.
public static boolean isConnectionPossible(Context context) {
try {
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connectivityManager.getNetworkInfo(MmsRadio.TYPE_MOBILE_MMS);
if (networkInfo == null) {
Log.w(TAG, "MMS network info was null, unsupported by this device");
return false;
}
getApn(context);
return true;
} catch (ApnUnavailableException e) {
Log.w(TAG, e);
return false;
}
}
use of android.net.ConnectivityManager in project remusic by aa112901.
the class NetworkUtils method isConnectInternet.
public static boolean isConnectInternet(final Context pContext) {
final ConnectivityManager conManager = (ConnectivityManager) pContext.getSystemService(Context.CONNECTIVITY_SERVICE);
final NetworkInfo networkInfo = conManager.getActiveNetworkInfo();
if (networkInfo != null) {
return networkInfo.isAvailable();
}
return false;
}
use of android.net.ConnectivityManager in project Android-Developers-Samples by johnjohndoe.
the class MainActivity method checkNetworkConnection.
/**
* Check whether the device is connected, and if so, whether the connection
* is wifi or mobile (it could be something else).
*/
private void checkNetworkConnection() {
// BEGIN_INCLUDE(connect)
ConnectivityManager connMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeInfo = connMgr.getActiveNetworkInfo();
if (activeInfo != null && activeInfo.isConnected()) {
wifiConnected = activeInfo.getType() == ConnectivityManager.TYPE_WIFI;
mobileConnected = activeInfo.getType() == ConnectivityManager.TYPE_MOBILE;
if (wifiConnected) {
Log.i(TAG, getString(R.string.wifi_connection));
} else if (mobileConnected) {
Log.i(TAG, getString(R.string.mobile_connection));
}
} else {
Log.i(TAG, getString(R.string.no_wifi_or_mobile));
}
// END_INCLUDE(connect)
}
use of android.net.ConnectivityManager in project FastDev4Android by jiangqqlmj.
the class JudgeNetWorker method getAPNType.
/**
* @author jiangqq
* 获取当前的网络状态 -1:没有网络 1:WIFI网络 2:wap网络 3:net网络
* @param context
* @return
*/
public static int getAPNType(Context context) {
int netType = -1;
ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
if (networkInfo == null) {
return netType;
}
int nType = networkInfo.getType();
if (nType == ConnectivityManager.TYPE_MOBILE) {
Log.e("networkInfo.getExtraInfo()", "networkInfo.getExtraInfo() is " + networkInfo.getExtraInfo());
if (networkInfo.getExtraInfo().toLowerCase().equals("cmnet")) {
netType = CMNET;
} else {
netType = CMWAP;
}
} else if (nType == ConnectivityManager.TYPE_WIFI) {
netType = WIFI;
}
return netType;
}
use of android.net.ConnectivityManager in project FastDev4Android by jiangqqlmj.
the class JudgeNetWorker method checkConnectionOk.
public static boolean checkConnectionOk(Context context) {
final ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
final NetworkInfo networkInfo = cm.getActiveNetworkInfo();
if (networkInfo == null || !networkInfo.isConnectedOrConnecting()) {
return false;
}
return true;
}
Aggregations