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
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(); }
From source file:Main.java
public static boolean isNetworkConnected(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); return ni != null && ni.isConnectedOrConnecting(); }
From source file:Main.java
public static boolean isMobileOrWifiConneciton(Context context) { ConnectivityManager connManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); NetworkInfo mMobile = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (mWifi.isAvailable() == false && mMobile.isAvailable() == false) { return false; }/*from ww w.j a v a2 s. c o m*/ return true; }
From source file:Main.java
public static boolean NetworkAvailable(Context context) { ConnectivityManager connectivity = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivity == null) { return false; } else {/*from w w w. ja v a 2s . 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 isNetworkAvailable(Context context) { ConnectivityManager connectivity = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivity == null) { return false; } else {/* w w w. ja va 2 s . com*/ 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 int getNetworkState(Context context) { final ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo wifiNetWorkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI); final NetworkInfo mobileNetWorkInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); if (wifiNetWorkInfo != null && wifiNetWorkInfo.isAvailable()) { return ConnectivityManager.TYPE_WIFI; } else if (mobileNetWorkInfo != null && mobileNetWorkInfo.isAvailable()) { return ConnectivityManager.TYPE_MOBILE; } else {/*from w ww. jav a 2 s .c o m*/ return -1; } }
From source file:Main.java
public static boolean getNetWorkState(Context context) { ConnectivityManager connectivityManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivityManager == null) { return false; }//from www .ja va2 s. com NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if (networkInfo == null || !networkInfo.isAvailable()) { return false; } return true; }
From source file:Main.java
public static boolean isConnectingToInternet(Context _context) { ConnectivityManager connectivity = (ConnectivityManager) _context .getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivity != null) { NetworkInfo[] info = connectivity.getAllNetworkInfo(); if (info != null) for (int i = 0; i < info.length; i++) if (info[i].getState() == NetworkInfo.State.CONNECTED) { return true; }/*from w w w .ja va 2 s .c o m*/ } return false; }
From source file:Main.java
public static boolean IsWifiAvailable(Context context) { ConnectivityManager m_NetConnectMgr = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); boolean bConnect = false; try {/*from w w w . j a va2s .c o m*/ if (m_NetConnectMgr == null) return false; NetworkInfo info = m_NetConnectMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); bConnect = (info.isAvailable() && info.isConnected()); } catch (Exception e) { return false; } return bConnect; }
From source file:Main.java
public static boolean isNetWorkAvalible(Context context) { ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (cm == null) { return false; }//from www . jav a2 s . co m NetworkInfo ni = cm.getActiveNetworkInfo(); if (ni == null || !ni.isAvailable()) { return false; } return true; }