List of usage examples for android.content Context CONNECTIVITY_SERVICE
String CONNECTIVITY_SERVICE
To view the source code for android.content Context CONNECTIVITY_SERVICE.
Click Source Link
From source file:Main.java
/** * Check if roaming connection active.// ww w. ja v a 2s .c o m * * @return */ private static boolean isConnectionRoaming(Context ctx) { ConnectivityManager cm = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); return ni != null && ni.isRoaming(); }
From source file:Main.java
public static boolean isConnectivity(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); return ((connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().getState() == NetworkInfo.State.CONNECTED) || telephonyManager.getNetworkType() == TelephonyManager.NETWORK_TYPE_UMTS); }
From source file:Main.java
public static boolean checkNetWorkIsAvailable(Context context) { ConnectivityManager conManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo network = conManager.getActiveNetworkInfo(); if (network != null) { return conManager.getActiveNetworkInfo().isAvailable(); }// ww w .j av a 2s. c om return false; }
From source file:Main.java
public static int getActiveNetworkType(Context context) { int defaultValue = -1; ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm == null) { return defaultValue; }// ww w .j a v a 2 s. com NetworkInfo info = cm.getActiveNetworkInfo(); if (info == null) { return defaultValue; } return info.getType(); }
From source file:Main.java
public static boolean isNetworkAvailable(Activity activity) { ConnectivityManager connectivity = (ConnectivityManager) activity .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivity == null) { return false; } else {/*from ww w . j a v a 2 s .c o m*/ NetworkInfo[] info = connectivity.getAllNetworkInfo(); if (info != null) { for (int i = 0; i < info.length; i++) { if (info[i].getState() == NetworkInfo.State.CONNECTED) { return true; } } } } return false; }
From source file:Main.java
public static boolean isWifiActive(Context context) { ConnectivityManager connectivity = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo[] info;//from w w w . j av a 2 s . c om if (connectivity != null) { info = connectivity.getAllNetworkInfo(); if (info != null) { for (int i = 0; i < info.length; i++) { if (info[i].getType() == ConnectivityManager.TYPE_WIFI && info[i].isConnected()) { return true; } } } } return false; }
From source file:Main.java
public static boolean isWifiReady(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo info = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); String ssid = getWifiSSID(context); if (info.isConnected() && ssid != null && !"".equals(ssid)) { return true; } else {//from w ww . java2 s.c om return false; } }
From source file:Main.java
public static Boolean checkNetworkConnect(Context context) { if (context != null) { ConnectivityManager mConnectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo(); if (mNetworkInfo != null) { return mNetworkInfo.isAvailable(); }/* w w w . j a va 2 s . com*/ } return false; }
From source file:Main.java
public static String getcurrentNetworkNoWifi(Context context) { String network_type = "UNKNOWN";// maybe usb reverse tethering NetworkInfo active_network = ((ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE)) .getActiveNetworkInfo();//from w ww .j a v a 2 s . c om if (active_network != null && active_network.isConnectedOrConnecting()) { network_type = active_network.getSubtypeName(); } return network_type; }
From source file:Main.java
public static boolean isInternetConnected(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); return networkInfo != null && networkInfo.isConnectedOrConnecting(); }